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

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

To verify login:
Code:
$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
}
else
{
	// 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
http://php.net/mysql

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