xQuasar Posted December 1, 2008 Share Posted December 1, 2008 Can anyone tell me why this script I made isn't working? It's supposed to check whether or not someone is logged in, and show a different set of menu buttons for both situations, but all that's happening is that it's showing the set for when it's logged in no matter what. >< <html> <head> </head> <body bgcolor="black"> <?php if($_SESSION['logged_in']=true) { ?> <font size="5" color="white" face="Lucida Handwriting,Arial"> </font> <br /> <form> <table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="index.php">Home</a></center><br /></font></td> </tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="coming.php">Forums</a><br /></center><br /></font></td> </tr> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="base.php">Base</a><br /></center><br /></font></td> </tr> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="coming.php">Etc.</a><br /></center><br /></font></td> </tr> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="logout.php">Logout</a><br /></center><br /></font></td> </tr> <tr> </table> </form> <?php } elseif($_SESSION['logged_in']=false) { ?> <br /> <form> <table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="index.php">Home</a></center><br /></font></td> </tr> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="login.php">Login</a><br /></center><br /></font></td> </tr> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="coming.php">Forums</a><br /></center><br /></font></td> </tr> <tr> <td width="100%"><font face="Verdana" color="white" size="4"><body vlink="white" alink="white" link="white" /> <center><a href="register.php">Register</a><br /></center><br /></font></td> </tr> </table> </form> <?php } ?> </body> </html> Thanks heaps! Link to comment https://forums.phpfreaks.com/topic/134963-solved-script-not-working-help/ Share on other sites More sharing options...
dimond345 Posted December 1, 2008 Share Posted December 1, 2008 You need start session by session_start(); function to access $_SESSION array; <?session_start();?> //your_code here Link to comment https://forums.phpfreaks.com/topic/134963-solved-script-not-working-help/#findComment-702900 Share on other sites More sharing options...
JonnoTheDev Posted December 1, 2008 Share Posted December 1, 2008 You are setting the session value rather than testing it: if($_SESSION['logged_in']=true) Should be if($_SESSION['logged_in'] == true) Link to comment https://forums.phpfreaks.com/topic/134963-solved-script-not-working-help/#findComment-702978 Share on other sites More sharing options...
The Little Guy Posted December 1, 2008 Share Posted December 1, 2008 You are setting the session value rather than testing it: if($_SESSION['logged_in']=true) Should be if($_SESSION['logged_in'] == true) or just: if($_SESSION['logged_in']) Link to comment https://forums.phpfreaks.com/topic/134963-solved-script-not-working-help/#findComment-703012 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.