I've got this code, I'm trying to make work for an authentication method for a site I'm developing. Right now, the code enters into an infinite loop going to index.php then to home.php and back again. Can someone direct me down the correct path? Thanks.
$address = "http://localhost/beta/ch";
$email = "email@email.com";
$cn = mysql_connect("localhost","root","");
$db = mysql_select_db('db);
$user = "$username";
if (!isset($HTTP_COOKIE_VARS["$user"])) {
$cn;
$db;
$result = mysql_query("select * from table where username = '$username' and password = '$password'");
if ($result){
setcookie("clubhouse", "$user");
header("Location:$address/home.php");
} else {
header("Location:$address/index.php");
};
};