Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's my full code. I pretty much rewrote the whole thing, so I appologize if the coding style differs too much:</p> <pre><code>&lt;?php // Output our CSS code echo '&lt;style type="text/css" media="screen"&gt; .error { color: red; } &lt;/style&gt;'; // Define our variable $problem = false; // Check if the form has been submitted if (isset($_POST['submitted'])) { // If either user or password are empty, we have a problem if (empty($_POST['username']) || empty($_POST['password'])) { $problem = TRUE; } // If there is no problem, username is user, and password is abc123, we're good if (!$problem &amp;&amp; $_POST['username']=='user' &amp;&amp; $_POST['password']=='abc123') { // Print our login message echo 'Thank you for logging in!&lt;br /&gt;'; } // Ok, there's either a problem or the username or password is wrong, so no entry for them else { echo '&lt;p class="error"&gt;No entry!&lt;/p&gt;'; } } ?&gt; &lt;form action="login.php" method="post"&gt; Username: &lt;input type="text" name="username" size="20" value="&lt;?php if (isset($_POST['submitted']) &amp;&amp; !empty($_POST['username'])) { echo $_POST['username']; } ?&gt;" /&gt; &lt;?php if (isset($_POST['submitted']) &amp;&amp; empty($_POST['username'])) { echo '&lt;span class="error"&gt;Please enter a username!&lt;/span&gt;'; } ?&gt; &lt;br /&gt;Password: &lt;input type="password" name="password" size="20" value="&lt;?php if (isset($_POST['submitted']) &amp;&amp; !empty($_POST['password'])) { echo $_POST['password']; } ?&gt;" /&gt; &lt;?php if (isset($_POST['submitted']) &amp;&amp; empty($_POST['password'])) { echo '&lt;span class="error"&gt;Please enter the password!&lt;/span&gt;'; } ?&gt; &lt;br /&gt;&lt;input type="submit" value="Log in" /&gt; &lt;br /&gt;&lt;input type="hidden" name="submitted" value="true" /&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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