Okay, I got that part of it to work but now it is not registering the cookie. I know I have probley asked this before, but I am not getting it. I don't really understand cookies.
My program starts after the username and password are sent from the browser, to the login program, A simple program which calls a function...
<?
Require_Once("functions.php");
login($username, $password);
?>
The login function works like this:
function login($username, $password) {
sleep(1);
$connection = dbconnect();
if (!$connection) {
}
$query = "select * from User
where username ='$username'
and password ='$password' ";
$result = mysql_query("$query");
if (!$result) {
echo "<b>ERROR:</b> Could not get query...<br>";
}
if (mysql_num_rows($result) > 0) {
//echo "okay";
$cae = checkvaliduser();
if ($cae) {
setcookie("siteuser", "$username", time()-3600);
}
setcookie("siteuser","$username",time()+3600);
echo "<META HTTP-EQUIV=REFRESH CONTENT=0;URL=logedin.php>";
}
else {
echo "<font color=red>That username doesn't exist or the password is incorrect<br>";
}
}
Then, the logged in page looks like this.
<?
Require_Once('functions.php');
$vu = checkvaliduser();
if (!$vu) {
echo "IT DIDN'T WORK!";
echo "<META HTTP-EQUIV=REFRESH CONTENT=5;URL=index.php>";
}
else {
$validuser = $HTTP_COOKIE_VARS['siteuser'];
echo "You have been logged in sucsessfully! <br>";
echo "\$validuser = $validuser";
echo "<META HTTP-EQUIV=REFRESH CONTENT=5;URL=index.php>";
}
?>
It checks to see if the cookie is registered by calling the checkvaliduser function:
function checkvaliduser() {
if (isset($HTTP_COOKIE_VARS['siteuser'])) {
return true;
}
else {
return false;
}
}
But the cookie is not registerd! I also commented out that checkvaliduser function to see if it was that that just wasn't working. No luck. What do I have to do to make this stupid program work?
And BTW, thanks for all the help from everyone.