This exactly solves what you’re asking it to do. This is code that is NOT being used for production yet, but so far it hasn’t failed.
It uses MySQL, PHP and Sessions. (Overkill for what you’re trying to accomplish and there are things that can be optimized in code…but you might gather some ideas from it.)
For obvious reasons, I’ve changed the MySQL, domain, username and password info.
The BINARY password reference forces the query to match the case. That is, if the password is catsup, the user must match the case and Catsup would fail.
$Link=mysql_connect("mysqldomain.dreamhost.com", "databaseusername", "databaseuserpass");
$Query="Select * from login2";
$Result=mysql_db_query($Dbname, $Query, $Link);
Print "Database connection failed.";
$Query2="Select * from login2 where userid = '$UserName' and BINARY password='$Password'";
$chkRes = mysql_num_rows($Result2);
If ($chkRes > 0)
while ($row = mysql_fetch_array ($Result2))
$CookieVal="$cust_num" . "$UserName";
#setcookie("JimsCookie", "", time()-100);
print "Form Results";
print "Good Login
print "Successful Login...";
print "Invalid Login";
print "Sorry. The userid and/or password you entered were incorrect.
echo "Click here to try again.
echo "Or, if you are a new user, you need to signup by clicking here.