Hello,
I have two scripts that previously worked independently, and I'm trying to combine them into one header for my member pages... one script checked for session, another for a "keep me logged in" cookie... if neither the session or the "keep me logged in" cookie (which is checked aganst a DB to make sure the user is still a current member) exist... the user is sent back to the login page.
Here's the script... I do believe problem I'm having has to do with misplaced (or missing?) curly brackets. {}
<?php
session_set_cookie_params (0, '/', '.domain.com');
session_start();
if($logged_in) {
}else{
MySQL_connect("localhost", '******', '******'); MySQL_select_db("users");
if (isset($_COOKIE['cookname'])) {
$_SESSION['user'] = $_COOKIE['cookname'];
}
$user = $_SESSION['user'];
$sql = "SELECT user
FROM users
WHERE user = '$user'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) == 1) {
// the user id is verified,
// set the session
$_SESSION['logged_in'] = true; }
}else{
/* Variables are incorrect, user not logged in */
setcookie("cookname", $_SESSION['user'], time()-3600, "/");
header('Location: login.php?redir='.$_SERVER['PHP_SELF']);
exit;
}
?>
Thanks once again.