0

I am desperate for some password protection that accesses a database for user name and password. i have searched all over the web and cannot find one that actualy works. i need to redirect to a users personal internal page on my website after the password checks out as well. any help would be greatly appreciated. thank you in advance.

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by StatiX
0

just make an html form that accepts two vars..user and pass then your code should look something like this

$sql = "SELECT * FROM `users` WHERE "user" = $_POST['user'] AND `pass`=$_POST['pass']";

$query= mysql_query($sql);
if(mysql_num_rows($query) => 1) {   //there is a user with that name and pass
//user authenticated .. proceed
echo "Welcome user!";
} else {
//user login failed do something else
echo "User name and password mismatch";
}

Of course you would not want to use the code above without first cleansing the two variables using some sort of filter. mysql_real_escape_string() , rtrim(), and md5() need to be implemented on the two variables if the pass is encrypted in the db

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.