I have the following code:
<?php
include("localsettings.php");
// Grab login info
if ((!empty($_POST['username'])) && (!empty($_POST['password']))) {
$username = $_POST['username'];
$pass = $_POST['password'];
if (!empty($_POST['rememberme'])) {$rememberme = $_POST['rememberme'];}else{$rememberme = "";} // Will be 1 if checked and nothing if not
$hashedpass = hash('sha256', $pass); // Hash with sha256
if (file_exists("users/" . $username . ".txt")) {
$filepass = file_get_contents("users/" . $username . ".txt");
if ($filepass == $hashedpass) {
if ($rememberme = 1) {
setcookie('username', $username, time()+60*60*24*365, '/', $server);
setcookie('password', $hashedpass, time()+60*60*24*365, '/', $server);
} else {
setcookie('username', $username, false, '/', $server);
setcookie('password', $hashedpass, false, '/', $server);
}
print_r($_COOKIE);
//header ('HTTP/1.1 301 Moved Permanently');
//header ('Location: ' . $site);
} else {
// Right username, wrong pass
echo ("Icorrect Password. <a href=\"" . $site . "/index.php?title=Special[UserLogin]\">Try Again</a>?");
}
} else {
// Wrong Username
echo ("Incorrect Username. <a href=\"" . $site . "/index.php?title=Special[UserSignup]\">Signup</a>?");
}
} else {
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: ' . $site . '/index.php?title=Special[UserLogin]');
}
?>
It outputs Array() even when passed a username and password from a different page. The reason for the weird links is I am creating a CMS for my site.