Code: Select all
<?php
session_start();
header("Cache-control:private");
mysql_connect('localhost', '***', '*****');
mysql_select_db('*********');
if(isset($_POST['rememberme'])){
$realname = mysql_query("SELECT username AS `name` FROM users WHERE username = '{$_POST['username']}'") or die(mysql_error());
$real = mysql_fetch_assoc($realname);
setcookie("log", $real['name'], time()+2342342);
}
?>
<head>
<title>Login: The Obvious Reasons</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<?php
$name = $_POST['username'];
$password = $_POST['password'];
$q = mysql_query("SELECT username, password, firstname
FROM users WHERE LOWER(username)=LOWER('$name')
AND LOWER(password)=LOWER('$password') AND valid=1") or die(mysql_error());
if(mysql_num_rows($q) > 0){
$row = mysql_fetch_assoc($q);
echo "Logging you in...";
echo "<META http-equiv='refresh' content='0;index.php'>";
$_SESSION['firstname'] = ucfirst($row['firstname']);
$_SESSION['username'] = $row['username'];
}else{
echo "Error: ".mysql_error();
echo "<p>Couldn't log you in.</p>";
}
?>Code: Select all
$name = $_POST['username'];
$password = $_POST['password'];The logout is also throwing me...
Code: Select all
<?php
session_start();
if(isset($_COOKIE['log'])){
setcookie("log", '', time()-3999);
}
?>
<head>
<title>Logout...</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<?php
$_SESSION = array();
if(!isset($_COOKIE['log'])){
echo "Logging you out...";
echo "<META http-equiv='refresh' content='2;http://****.com>";
}else{
echo "Error...";
print_r($_COOKIE);
}
?>Any ideas? I'm pretty flabbergasted on this one.
Thanks