well there is quite a work to do here. lets start:
first you need a login form, which will take the login data from user i.e. ID & passwd.
name them ID and passwd in NAME argument of INPUT fields in FORM.
then the ACTION of the form should call the script which you have mentioned above. where you can check the ID and passwd with your db, whether its valid or not.
remember in php you can simply use $ID as variable which is same as the NAME from the FORM that is passed over to the PHP script.
so we do:
mysql_connect('host', 'userid', 'passwd');
mysql_select_db('your_db_name');
// finds the user if exists in table
$sql = "SELECT id, passwd
FROM user_table
WHERE id = '$ID' AND passwd = '$passwd'";
// executes the SQL to mySQL db
$result = mysql_db_query('db_name', $sql);
// gets the record from db.
// if no rows found, it means the
// user ID and passwd entered is not valid.
$num_of_rows = @mysql_num_rows($result);
// if user ID and passwd is not found in db
// i.e. result row is less than 1
if ($num_of_rows < 1) {
// call error message here ...
mysql_close();
exit();
}
else {
// direct to welcome page ...
mysql_close();
exit();
}
i hope this is what you are looking for 🙂
regards,
Daarius ...