heres one I made earlier :
<?php include "mysql_data.php";
$id = $username;
setcookie("userid","$id","mktime(0,0,0,0,0,2020)");
$userid = $HTTP_COOKIE_VARS["userid"];
mysql_connect("$host","$login","$pass")
or die ("Unable to connect to database");
mysql_select_db("$swadb")
or die ("Unable to select Database.");
$sql = "SELECT id
FROM swa_members
WHERE name='$username' and pass_word='$password'";
$result = mysql_query($sql) or die ("Couldn't get Results");
$num = mysql_numrows($result) or die ("Couldnt get count.");
if ($num == 1) {
echo "LOGIN SUCCESSFUL";
} else {
echo "LOGIN FAILURE";
}
?>
hope this is of some help