Salve, sto cercando di creare ina script che verifichi se gli utenti sono loggati.Se no, li reidirizza alla pagina di login.
...sono in alto mare.Sotto posto il codice checkuser.php..
Qualche idea???
GRAZIE IN ANTICIPO
<?
session_start(); // Start Session
include 'db.php';
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information!
";
include 'index.php';
exit();
}
$password = md5($password);
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
header("Location: index.php");
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!
Please try again!
";
include 'login.php';
}
?>