Page 2 of 2

Posted: Tue Jan 17, 2006 11:05 am
by gamer13
How do I check if the info is correct? (This is for the login page) How do I check the info with the database? :?

Posted: Tue Jan 17, 2006 11:10 am
by phpdevuk
you need to run a query against the db to get the user details that are valid, and then compare the ones submitted to these to see if they are correct.

basic example

Code: Select all

if($_REQUEST['username']!=""&&$_REQUEST['password']!=""){

$sql = "SELECT * FROM users WHERE users.username='".$_REQUEST['username']."' AND users.password='".$_REQUEST['password']."'";

$result = mysql_query($sql);

$num = mysql_num_rows($result);

if($num!=0){

// do login stuff



}
else{

// user not logged in

}

}
else{

// blank login details do something



}