Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP if-statement being 'ignored', rendering both options
    text
    copied!<p>So I am extremely new to PHP and am probably making a stupid mistake. I have searched for quite a while, though, and have not been able to figure out what is going wrong.</p> <p>Using XAMPP all of the PHP works fine. When I load it onto my web server, however, the if statement regulating the log in form displays both the 'log in' form and the 'log out' form at the same time. Obviously not what I want!</p> <p>Here is the code snippet:</p> <pre><code>&lt;?php if ( isset( $_SESSION['email'] ) ) { // Check to see if user is logged in. If so, display log out button. ?&gt; &lt;form class="navbar-form pull-right" action="logout.php" method="POST"&gt; &lt;button name="submit" type="submit" class="btn btn-success"&gt;Log Out&lt;/button&gt; &lt;/form&gt; &lt;?php } else { // display log in form ?&gt; &lt;form class="navbar-form pull-right" action="login.php" method="POST"&gt; &lt;input name="email" type="text" class="span2" placeholder="email"&gt; &lt;input name="password" type="password" class="span2" placeholder="password"&gt; &lt;button name="submit" type="submit" class="btn btn-success"&gt;Log In&lt;/button&gt; &lt;/form&gt; &lt;?php } ?&gt; </code></pre> <p>This is contained in a file index.php</p> <p>The basic logic is test to see if an email variable has been created for the session (done in a login.php execution) to check if the user is logged in.</p> <p>I have no idea if this is the best way to create a log in, but that's what I've tried to do.</p> <p>Again, I am very new to this, so any insight on where to look next would be greatly appreciated!</p> <p>Thank you!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload