chanfuterboy Posted November 6, 2009 Share Posted November 6, 2009 hi, i want to just if username is online it show menu.php if not show the html fields, what is the thing that i dont wrong plz help. ?> if(isset($_SESSION["username"])) { include('menu.php'); echo "Welcome, ".$_SESSION['username']; } else { ?> <form action="login.php" method="post"> <p align="right"><label><b>Username:</b> <input type="text" name="username" size="10" value="<? echo $username; ?>"></label> <label><b>Password:</b> <input type="password" name="password" size="10" value=""></label> <input type="submit" value="Login!"> </p> </form> Link to comment https://forums.phpfreaks.com/topic/180572-solved-if-else/ Share on other sites More sharing options...
rajivgonsalves Posted November 6, 2009 Share Posted November 6, 2009 according to the code specified ?> <-- php tag closes if(isset($_SESSION["username"])) how will the code run ? also where are you setting the username value in session, can' say much with this code you have presented Link to comment https://forums.phpfreaks.com/topic/180572-solved-if-else/#findComment-952657 Share on other sites More sharing options...
mrMarcus Posted November 6, 2009 Share Posted November 6, 2009 the closing ?> before you start your PHP can't help either .. not sure if it's just a typo. and, do you have session_start() at the top of your script(s)? Link to comment https://forums.phpfreaks.com/topic/180572-solved-if-else/#findComment-952659 Share on other sites More sharing options...
chanfuterboy Posted November 6, 2009 Author Share Posted November 6, 2009 if i try if($_SESSION['username']) { include('menu.php'); echo "Welcome, ".$_SESSION['username']; } else { <form action="login.php" method="post"> <p align="right"><label><b>Username:</b> <input type="text" name="username" size="10" value="<? echo $username; ?>"></label> <label><b>Password:</b> <input type="password" name="password" size="10" value=""></label> <input type="submit" value="Login!"> </p> </form> ?> It distroy the htm pag Link to comment https://forums.phpfreaks.com/topic/180572-solved-if-else/#findComment-952664 Share on other sites More sharing options...
mikesta707 Posted November 6, 2009 Share Posted November 6, 2009 <?php if($_SESSION['username']) { include('menu.php'); echo "Welcome, ".$_SESSION['username']; } else { ?> <form action="login.php" method="post"> <p align="right"><label><b>Username:</b> <input type="text" name="username" size="10" value="<? echo $username; ?>"></label> <label><b>Password:</b> <input type="password" name="password" size="10" value=""></label> <input type="submit" value="Login!"> </p> </form> <?php } ?> try that? [/code] Link to comment https://forums.phpfreaks.com/topic/180572-solved-if-else/#findComment-952667 Share on other sites More sharing options...
chanfuterboy Posted November 6, 2009 Author Share Posted November 6, 2009 yes i just come back to tell that last part <?php } ?> bye Link to comment https://forums.phpfreaks.com/topic/180572-solved-if-else/#findComment-952669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.