Login Form won't take login information
<p>I have a database set up with email and password, I'm trying to use the code below to check the username(email) and password to make sure they're correct and if they are send them to /cms if they don't match, a pop up box comes up. I'm only getting pop up to work. Can you see any issues that would be causing that?</p>

<pre><code>session_start();

require_once("../mydbpassword.php");
if($_POST['username']) {

$username = $_POST['username'];
$password = $_POST['password'];

$sql = "SELECT * FROM agents WHERE email = '$username' AND pword = '$password'";
$result = mysqli_query($mysqli,$sql);

$email = $row['email'];
$pword = $row['pword'];

if(($username != $email) || ($password != $pword)) {
echo'&lt;script type="text/javascript"&gt;
    window.alert("Your login information is wrong, try again!");
    window.location="/cms/login"
    &lt;/script&gt;';
}
else {
$row = mysqli_fetch_assoc($result);
$_SESSION['admin'] = $row['$email'];
header("Location: /cmsS");
exit();

}
  }
</code></pre>
