PHP Login Code With Username Error : <p>I'm writing the code for a login. I've gotten the code from another resource. Everything seems to be okay, but it keeps telling me that the Alumni_ID (the username) does not exist- even though it does. </p>

<p>The php code for the login:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>  &lt;?php
  error_reporting(E_ALL); ini_set('display_errors', 1);

 $servername = getenv('IP');
 $username = getenv('C9_USER');
 $password = "";
 $database = "c9";
 $dbport = 3306;
  $conn = mysqli_connect($servername,$username,"",$database,$dbport) or die(mysqli_error());
  if($_SERVER["REQUEST_METHOD"] == "POST"){
	
	
	$query = mysql_query("SELECT Alumni_ID, Password from 'Alumni' WHERE Alumni_ID='$Alumni_ID'"); //Query the Alumni table if there are matching rows equal to $Alumni_ID
	
	$exists = mysql_num_rows($query); //Checks if Alumni_ID exists
	$table_Alumni = "";
	$table_Password = "";
	
	if($exists = 0) //IF there are no returning rows or no existing Alumni_ID
	
	    {
                		while($row = mysql_fetch_assoc($query)) //display all rows from query
                		{
                			$table_Alumni_ID = $row['Alumni_ID']; // the first Alumni_ID row is passed on to $table_Alumni, and so on until the query is finished
                			$table_Password = $row['Password']; // the first Password row is passed on to $table_Alumni, and so on until the query is finished
                		}
                		if(($Alumni_ID == $table_Alumni_ID) &amp;&amp; ($Password == $table_Password)) // checks if there are any matching fields
                		{
                				if($Password == $table_Password)
                				{
                					$_SESSION['user'] = $Alumni_ID; //set the Alumni_ID in a session. This serves as a global variable
                					header("location: loggedalumni/index.php"); // redirects the user to the authenticated home page
                				}
                				
                		}
                		else
                		{
                			Print '&lt;script&gt;alert("Incorrect Password!");&lt;/script&gt;'; //Prompts the user
                			Print '&lt;script&gt;window.location.assign("index.php");&lt;/script&gt;'; // redirects to login.php
                		}
	}
	else
	{
		Print '&lt;script&gt;alert("Incorrect Username!");&lt;/script&gt;'; //Prompts the user
		Print '&lt;script&gt;window.location.assign("index.php");&lt;/script&gt;'; // redirects to login.php
	}
}
?&gt;</code></pre>
</div>
</div>
</p>

<p>And this is the form:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="col-lg-12"&gt;
                                &lt;div class="nav-link" style= "text-align: center;"&gt;&lt;h3&gt;&lt;b&gt;Log In&lt;/b&gt;&lt;/h3&gt;&lt;/div&gt;
                                &lt;form id="ajax-login-form" action=" " method="post" role="form" autocomplete="off"&gt;
                                    &lt;div class="form-group"&gt;
                                        &lt;label for="Alumni_ID" style= "text-align: center;"&gt;Alumni ID&lt;/label&gt;
                                        &lt;input type="text" name="Alumni_ID" tabindex="1" class="form-control" placeholder="Your Alumni ID" value="" autocomplete="off"&gt;
                                    &lt;/div&gt;

                                    &lt;div class="form-group"&gt;
                                        &lt;label for="password" style= "text-align: center;"&gt;Password&lt;/label&gt;
                                        &lt;input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="Password" autocomplete="off"&gt;
                                    &lt;/div&gt;

                                    &lt;div class="form-group"&gt;
                                        &lt;div class="row row-centered" style="padding-left:20px"&gt;
                                            &lt;div class="col-xs-7"&gt;
                                                &lt;input type="checkbox" tabindex="3" name="remember" id="remember"&gt;
                                                &lt;label for="remember" style= "align: center;"&gt; Remember Me&lt;/label&gt;
                                            &lt;/div&gt;
                                            &lt;/div&gt;
                                            &lt;div class="row row-centered"&gt;
                                            &lt;div class="col-xs-5" style="padding-left:75px"&gt;
                                                &lt;input type="submit" name="login-submit" id="login-submit" tabindex="4" class="form-control btn btn-success" style="background-color: #6a0001;" value="Log In" align="middle"&gt;
                                            &lt;/div&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;

                                    &lt;div class="form-group"&gt;
                                        &lt;div class="row"&gt;
                                            &lt;div class="col-lg-12"&gt;
                                                &lt;hr&gt;
                                                &lt;div style="padding-left:10px"&gt;
                                                    &lt;a href="recover.php" tabindex="5" class="forgot-password" style = "color: black"&gt;Forgot Password?&lt;/a&gt;
                                                &lt;/div&gt;
                                                &lt;hr&gt;
                                                &lt;div style="padding-left:10px"&gt;
                                                    &lt;a href="NewAlumni.php" tabindex="5" class="forgot-password" style = "color: black"&gt;Register Account&lt;/a&gt;
                                                &lt;/div&gt;
                                                &lt;hr&gt;
                                                &lt;div style="padding-left:10px"&gt;
                                                    &lt;a href="adminlogin.php" tabindex="5" class="forgot-password" style = "color: black"&gt;Admin Login&lt;/a&gt;
                                                &lt;/div&gt;

                                            &lt;/div&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                    &lt;input type="hidden" class="hide" name="token" id="token" value="a465a2791ae0bae853cf4bf485dbe1b6"&gt;
                                &lt;/form&gt;
                            &lt;/div&gt;</code></pre>
</div>
</div>
</p>
