2017-05-31 29 views
0

我有一個登錄欄,登錄後我想要轉換用戶名登錄。 login bar登錄後轉換php吧

index.php的登錄表單看起來就像是:

<form action="login.php" method="post"> 
     <input class="input_form_login_top" type="text" id="login_username" placeholder="username" name="login_username"required> 
     <input class="input_form_login_top" type="password" id="login_password" placeholder="password" name="login_password" required> 
     <button type="submit" name="submit" class = "button_login_top"> Login </button> 


    <button onclick="document.getElementById('id01').style.display='block'" style="width:auto;" class="button_signup_top"> Sign Up</button> 
</form> 
+1

歡迎[這麼]!在這個網站,你應該嘗試**自己編寫代碼**。後** [做更多的研究](//meta.stackoverflow.com/questions/261592)**如果你有問題,你可以**發佈你已經嘗試**與清楚的解釋是什麼是'工作**並提供[** Minimal,Complete和Verifiable示例**](// stackoverflow.com/help/mcve)。我建議閱讀[問]一個好問題和[完美問題](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/)。另外,一定要參加[遊覽]並閱讀[this](// meta.stackoverflow.com/questions/347937/)**。 –

+0

你可以用'$ _SESSION'來試試。 – AdhershMNair

+0

我有會議..我登錄..但我不知道該怎麼做後 – StringDotZ

回答

0

這是你在登錄欄中所需要的具有if語句,將檢查用戶是否已經登錄或不使用會話你,你在哪裏登錄頁面上的設置,那麼如果用戶的loggedIn顯示什麼都HTML內容你登錄欄上想要顯示或者顯示的登錄表單

<?php 
session_start(); 
    if(isset($_SESSION['whatEverYouCallIT']) && !empty($_SESSION['whatEverYouCallIT'])):?> 

      <!-- The user have logged display what ever html content you want here in the login bar --> 
     <a class="button_login_top" href="profile.php?user=<?=$_SESSION['whatEverYouCallIT']?>">Hell <? = $_SESSION['whatEverYouCallIT']?></a> 
     <a class="button_login_top" href="logout">Log out</a> 
    <?php 

     else : ?> 

     <!-- Display the html login form --> 
     <form action="login.php" method="post"> 
     <input class="input_form_login_top" type="text" id="login_username" placeholder="username" name="login_username"required> 
     <input class="input_form_login_top" type="password" id="login_password" placeholder="password" name="login_password" required> 
     <button type="submit" name="submit" class = "button_login_top"> Login </button> 


    <button onclick="document.getElementById('id01').style.display='block'" style="width:auto;" class="button_signup_top"> Sign Up</button> 
</form> 
<?php 

    endif; 
?> 
+0

這是我的整個代碼...我supose,我必須修改頁面,使我想要的更改... https://github.com/Stringshotz/ddbase – StringDotZ

+0

@StringDotZ頁未找到 –