So I made this basic login form as follows in html.I understand that it is lacking at the moment in security measures, but I just want it to simply be able to login first. Then I will build in the more advanced features.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Jotorres Login Form</title>
</head>
<body>
<form method="post" action="login.php" >
<table border="1" >
<tr>
<td><label for="users_name">Username</label></td>
<td><input type="text"
name="users_name" id="users_name"></td>
</tr>
<tr>
<td><label for="users_pass">Password</label></td>
<td><input name="users_pass"
type="password" id="users_pass"></input></td>
</tr>
<tr>
<td><input type="submit" value="Submit"/>
<td><input type="reset" value="Reset"/>
</tr>
</table>
</form>
</body>
</html>
Then I call login.php. I have a user in the RDS database called "tommytest" with a password of "tommytest" but it isn't working. Keeps saying incorrect username or password. But if I leave the form blank and hit submit it says I am verified.
<?php
// Grab User submitted information
$name = $_POST["users_name"];
$pass = $_POST["users_pass"];
// Connect to the database
$con = mysql_connect("localhost","username","password");
// Make sure we connected succesfully
if(! $con)
{
die('Connection Failed'.mysql_error());
}
// Select the database to use
mysql_select_db("ist421test",$con);
$result = mysql_query("SELECT userName AND password FROM users_tbl WHERE userName = '$name'");
$row = mysql_fetch_array($result);
if($row["userName"]==$name && $row["password"]==$pass)
echo"You are a validated user.";
else
echo"Sorry, your credentials are not valid, Please try again.";
?>