Earn Resources

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post 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? :?
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post 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



}
Post Reply