dtu15253
2016-03-16 14:29
浏览 67
已采纳

用户登录/注销时显示链接/按钮

I am truly a novice at coding and only succeed with trial and error. I use a WYSIWYG program to do all the main pages in my site and then add php coding to do some specified things.What I am trying to do right now is display a log in button along with a register and forgot password links to those forms, all of which I have built and working, have this display in the masterframe page when a user is not logged in and show another set of user name, profile, logout links when they are logged in. By themselves I have all these functions working, I just cant figure out how to do it this way. Any help or steering me in the right direction to teach me would be great. If you need to be paid for your help that can be arranged as well. Thank You.

update: This is the code that I have right now and use, again I want to have the if else statement show one thing or the other on condition, and have it show in place of, all on the masterframes page.

// have this display if user is logged in

<span id="LoginName1"><?php
if (isset($_SESSION['username']))
{
   echo $_SESSION['username'];
}
else
{
   echo 'Not logged in';
}
?></span>

<div id="wb_Text2" style="">
<span style="color:#FFFFFF;font-family:Tahoma;font-size:12px;"><a href="javascript:displaylightbox('./members/Edit_Profile.php',{width:620,height:710})" target="_self" class="style5">Profile</a></span>
</div>

<form name="logoutform" method="post" action="<?php echo basename(__FILE__); ?>" id="logoutform">
<input type="hidden" name="form_name" value="logoutform">
<a id="Logout2" href="javascript:document.logoutform.submit()">Logout</a>
</form>

//have this display if user is logged out

<a href="javascript:displaylightbox('./members/Log-In.php',{width:490,height:370})" target="_self" id="jQueryButton1" style="width:100%;height:100%;">Log In</a>

<div id="wb_Text3" style="">
<span style="color:#FFFFFF;font-family:Tahoma;font-size:12px;"><a href="javascript:displaylightbox('./members/Create_Account.php',{width:620,height:710})" target="_self" class="style5">Register</a></span>
</div>

<div id="wb_Text1" style="">
<span style="color:#FFFFFF;font-family:Tahoma;font-size:12px;"><a href="javascript:displaylightbox('./members/Forgot_Password.php',{width:350,height:275})" target="_self" class="style5">Forgot Password?</a></span>
</div>

I have tried doing this but I keep getting a syntax error for unexpected '<'

<span id="LoginName1"><?php
if (isset($_SESSION['username']))
{
   echo $_SESSION['username'];

<div id="wb_Text2" style="">
<span style="color:#FFFFFF;font-family:Tahoma;font-size:12px;"><a href="javascript:displaylightbox('./members/Edit_Profile.php',{width:620,height:710})" target="_self" class="style5">Profile</a></span>
</div>

<form name="logoutform" method="post" action="<?php echo basename(__FILE__); ?>" id="logoutform">
<input type="hidden" name="form_name" value="logoutform">
<a id="Logout2" href="javascript:document.logoutform.submit()">Logout</a>
</form>
}
else
{
<a href="javascript:displaylightbox('./members/Log-In.php',{width:490,height:370})" target="_self" id="jQueryButton1" style="width:100%;height:100%;">Log In</a>

<div id="wb_Text3" style="">
<span style="color:#FFFFFF;font-family:Tahoma;font-size:12px;"><a href="javascript:displaylightbox('./members/Create_Account.php',{width:620,height:710})" target="_self" class="style5">Register</a></span>
</div>

<div id="wb_Text1" style="">
<span style="color:#FFFFFF;font-family:Tahoma;font-size:12px;"><a href="javascript:displaylightbox('./members/Forgot_Password.php',{width:350,height:275})" target="_self" class="style5">Forgot Password?</a></span>
</div>
}
?></span>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

5条回答 默认 最新

相关推荐 更多相似问题