Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>&lt;?php if($_POST['username'] &amp;&amp; $_POST['password']){ $username = $_POST['username']; // Escape this $password = $_POST['password']; // Escape this $searchQuery = mysql_query("SELECT id FROM onlineformdata WHERE username = '$userName' AND password = '$password' ORDER BY id DESC LIMIT 1"); if(mysql_num_rows($searchQuery)){ header('location:/adminPage.php'); // Go to this page if row exists in DB } else{ header('location:/invalidLoginPage.html'); //Go to this page if row doesn't exist in DB } exit; // So that it quite this page and goes to the desired one set in the "headers" } else{ //Not strictly needed... But you could be useful in some circumstances } ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Admin Login&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action='' method="post"&gt; username: &lt;input type="text" name="username" /&gt; password: &lt;input type="text" name="password" /&gt; &lt;br/&gt; &lt;input type="submit" value="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This should get you started in the <em>right</em> direction. Don't forget to escape the username/password fields as you see fit.</p> <p>The <em>action</em> part of the form is where the form is submitted to and so - in your case - that should be the same page. As Hristo said, you can leave it out/blank and it will default to submitting itself.</p> <p>As for Marc B (he did ask a question after all); if you read the code you would see that the PrepSQL function actually adds single quotes around the string... As there are no quotes in the html this isn't wrong in anyway... So I don't see what the problem is there (aside from it not doing what he wanted it to).</p> <p>With regards to multiple user accounts, so long as you don't allow the same <em>username</em> to be used by multiple users then there is only one record returned by the database... So again, there's no problem there.</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