2014-09-22 118 views
0

我正在使用PHPmotion腳本:http://demo.phpmotiontemplates.com/default/ 我成功地使登錄表單(在主頁上)消失,一旦它成功執行它的功能(這正是我想要完成的),但只要登錄功能成功,並且主頁上的「子菜單」出現,登錄表單又會再次出現(在主頁上) 。如何防止登錄表單再次出現

所以,我假設子菜單與登錄表單重新出現有關。

,看起來像這樣:

<form action="../login.php" method="post" accept-charset="UTF-8" class="middletext" 
onsubmit="javascript:this.style.display='none';"> 
<p> 
<input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER  USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if  (this.value=='ENTER USERNAME') {this.value=''; this.style.color='#696969';}" > 
<input type="text" size="20" name="password_login" id="password_login" value="ENTER  PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if  (this.value=='ENTER PASSWORD') {this.value=''; this.style.color='#696969';}" > 
<input type="hidden" name="cookie_time" value="10080" /> 
<img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" /> 
<input type="hidden" name="submitted" value="yes" /> 
<input type="hidden" name="remember_me" value="remember_me" /> 
</p> 
</form> 
</div> 
<!--Begin Sub-Navigation. This only appears when a user is logged in.--> 
<div class="container1"> 
<div class="menu1"> 
<div class="sub-nav"><a href="../index.php"></a>&nbsp;<img  src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /><a href="../members/[var.user_name]"> my account</a><img src="../themes/default/images/arrow- red.jpg" style="vertical-align:middle" alt="" /> 
<a href="../credits.php">[var.lang_my_credits]: [var.member_credits]</font></a><img  src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle"><a  href="../logout.php">[var.login_out]</a> 
<!--[onload;block=div;when [var.loggedin]=1;comm]--> 
</div> 

任何想法/這個解決方案將不勝感激。

+2

'if($ _ SESSION ['loggedin'] == true){// dont show form} else {// show form}' – Daan 2014-09-22 14:33:17

+0

謝謝。你能告訴我哪裏/如何將它整合到表單代碼中嗎? – 2014-09-22 14:58:29

回答

0
<?php 

    if(!isset($_SESSION['YOUR-SESSION-NAME'])){ 

     echo '<form action="../login.php" method="post" accept-charset="UTF-8" class="middletext" 
    onsubmit="javascript:this.style.display=\'none\';"> 
    <p> 
    <input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER  USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if  (this.value==\'ENTER USERNAME\') {this.value=\'\'; this.style.color=\'#696969\';}" > 
    <input type="text" size="20" name="password_login" id="password_login" value="ENTER  PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if  (this.value==\'ENTER PASSWORD\') {this.value=\'\'; this.style.color=\'#696969\';}" > 
    <input type="hidden" name="cookie_time" value="10080" /> 
    <img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" /> 
    <input type="hidden" name="submitted" value="yes" /> 
    <input type="hidden" name="remember_me" value="remember_me" /> 
    </p> 
    </form> 
    </div> 
    <!--Begin Sub-Navigation. This only appears when a user is logged in.--> 
    <div class="container1"> 
    <div class="menu1"> 
    <div class="sub-nav"><a href="../index.php"></a>&nbsp;<img  src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /><a href="../members/[var.user_name]"> my account</a><img src="../themes/default/images/arrow- red.jpg" style="vertical-align:middle" alt="" /> 
    <a href="../credits.php">[var.lang_my_credits]: [var.member_credits]</font></a><img  src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle"><a  href="../logout.php">[var.login_out]</a> 
    <!--[onload;block=div;when [var.loggedin]=1;comm]--> 
    </div>'; 

} else { 

    echo 'You\'re already logged in!'; 

} 

?>