View Single Post
Old 29th November 2007, 16:51
Mosquito Mosquito is offline
Join Date: Nov 2006
Posts: 85
Thanks: 5
Thanked 6 Times in 5 Posts

Assuming you have only a Text Field for User name and password - named 'username' and 'password',

To verify login:
$query = "SELECT username, password, other_fields FROM users_table WHERE username = $_REQUEST['username'] AND password = encrypt($_REQUEST['password'])";
$result = mysql_query($query) or die('Query failed: ' . mysql_error()); 

if (mysql_num_rows($result) == 1)
	//successful login
	// not successful
I just wrote this code up now, so I haven't tested it. However, it should work with few modifications. What this script does it make sure only 1 row is returned (matching username and password...hopefully those are unique on your database). The query itself, will use the MySQL encrypt() function to compare the input password to what is in the database.

If you have PHP/MySQL questions, take a look at

Last edited by Mosquito; 29th November 2007 at 16:54.
Reply With Quote