Use PHP to match username & password with HTML drop down
<p>I have a MySQL database called school that is set up like this:
schoolID(1), schoolName(school 1), schoolCounty(Buckinghamshire), schoolUsername(school1admin), schoolPassword(school1password)</p>

<p>I currently have a drop down menu that shows the list of schools and when I type any username and password into the HTML login form I can log in.</p>

<p>I can't seem to work out how I can set it so, depending on the school selection will depend on what username and password to use.</p>

<p>For example, if i select school1 then i can ONLY use school1's username and password.</p>

<p>This is what I have so far for index.php:</p>

<pre class="lang-html prettyprint-override"><code>&lt;?php

require_once 'databaseConnect.php';  // connects to the databse via this file
if ($conn-&gt;connect_error) die ($conn-&gt;connect_error); // check the connection to the database. If failed, display error


$sql = "SELECT * FROM school";
$result = $conn-&gt;query($sql);


$conn-&gt;close();
?&gt;  


&lt;html&gt;
    &lt;body&gt;
        &lt;title&gt;EduKode&lt;/title&gt;




       &lt;div id="login-form-container"&gt;
           &lt;p&gt;Log In:&lt;/p&gt;

&lt;?php
echo'&lt;div id="schoolSelection"&gt;';
echo '&lt;select name="schoolName"&gt;';
if ($result-&gt;num_rows &gt; 0) {
// output data of each row
while($row = $result-&gt;fetch_assoc()) {
echo '&lt;option&gt;'. $row["schoolName"].  "&lt;br&gt;";
}
} else {
echo "0 results";
}
echo '&lt;/select&gt;';

echo'&lt;/div&gt;';

//http://stackoverflow.com/questions/10009464/fetching-data-from-mysql-database-to-html-dropdown-list
?&gt;

                &lt;form id="login-form" name="contactform" method="post" action="checkSchoolCredentials.php"&gt; &lt;!-- when submitting the form will call the 'authenticate.php' script.--&gt;
                    &lt;div class="contact-form"&gt;

                        &lt;label&gt;Username:&lt;/label&gt;
                        &lt;input name="username" type="text"&gt; &lt;!-- students created username field--&gt;

                        &lt;label&gt;Password:&lt;/label&gt;
                        &lt;input name="password" type="password"&gt; &lt;!-- students created password field--&gt;
                    &lt;/div&gt;
                        &lt;div id="submit-button"&gt;
                            &lt;input type="submit" name="submit" value="Log In"&gt;
                        &lt;/div&gt;
                &lt;/form&gt;
        &lt;/div&gt;

    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>This is for checkSchoolCredentials.php:</p>

<pre class="lang-html prettyprint-override"><code>&lt;?php
require_once 'databaseConnect.php';  // connects to the databse via this file
if ($conn-&gt;connect_error) die ($conn-&gt;connect_error); // check the connection to the database. If failed, display error


if(isset($_POST['submit'])) // if submit button is pressed
{
    $username = $_POST['username']; //assigns the value of the input box username to $username
    $password = $_POST['password']; //assigns the value of the input box password to $password

    $query = "SELECT * FROM school WHERE schoolUsername='$username' AND schoolPassword ='$password'"; // Query the database 


    $result=mysqli_query($conn, $query);
    if(mysqli_num_rows($result) ==1)
    {
        session_start(); // start session 
        $_SESSION['auth']='true';
        $_SESSION['username'] = $username; // save session as username
        header('location:taskSelection.php'); // if correct, redirect to taskSelection.php

    }
    else
    {
        header('location:index.php'); // redirect to index.html if incorrect


    }

}


$conn-&gt;close();

?&gt;
</code></pre>