Jump to content

Problem with if statement


PHPiSean

Recommended Posts

So basically I've been experimenting with setting cookies and sessions. The code in my header file will display a login if there is no $_SESSION['username']. However, the else statement verifies that there is, and echo's "hello." My problem lies in the else statement, when the login form disappears, but nothing in the else statement appears. Here's the code, I feel like I am missing something obvious.

 

<?php
if (!isset($_SESSION['username'])){
echo "<li><a href='register.php'>Register</a></li>";
echo "</ul>";
  echo "
    <table>  
    <tr>
    <form name='login' method='post' action='login.php'>
    <tr><td>Username</td> <td><input type='text' name='username'></td></tr>
    <tr><td>Password</td> <td><input type='password' name='password'></td></tr>
    <tr><td><input type='submit' name='submit' value='Login'></td></tr>
    <tr><td><input type='checkbox' name='rememberme' value='remember'> Remember</td></tr>
    </form>
    </table>
";
}else{
echo "hello";
}

?>

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/245399-problem-with-if-statement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.