Hey, For some reason $password (the one being sent form the form) is coming up blank.
I am manually checking for this with this code:
echo "<p>$username does not match $firstandlast</p>";
echo "<p>$password does not match $dbpassword</p>";
here is my code...
<?php
if(isset ($_POST['submit'])) {
$username = $_POST['name'];
$password = $_POST['pw'];
if ($username&&$password){
require('includes/cxn.php');
$login_query = "SELECT * FROM users WHERE username='$username'";
$result = mysqli_query($cxn,$login_query) or die("Couldn't execute query.");
$numrows = mysqli_num_rows($result);
if($numrows!=0){
while ($row = mysqli_fetch_assoc($result))
{
$firstandlast = $row['firstName'] . " " . $row['lastName'];
$dbpassword = $row['password'];
$userID = $row['userid'];
if ($username==$firstandlast&&$password==$dbpassword){
echo "You are now logged in! <a href='profile.php?userID=" . $userID . "'>Click Here</a> to continue.";
$_SESSION['username'] = $dbusername;
$_SESSION['id'] = $userID;
}
else {
echo "<p>$username does not match $firstandlast</p>";
echo "<p>$password does not match $dbpassword</p>";
echo "Password does not exist.";
}
}
} else {
echo "This user doesn't exist.";
}
} else {
die("You Must Enter both a username and password");
}
} else {
echo "
<div id='login'>
<form action='login.php' method='post' id='loginform'>
<table>
<tr>
<td width='90'>Name:</td>
<td width='825'><input type='text' name='name' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='pw' /></td>
</tr>
<tr>
<td> </td>
<td><button type='submit' name='submit'>Sumbit</button></td>
</tr>
</table></form></div>";
}
?>