I have been trying like heck to get my login code working. Everything 'seems' alright.
login.php
<?php session_start(); ?>
<html>
<head>
<title>Brent's Realm - Login</title>
<?php
include("./includes/header.tpl");
include("./includes/navigation.tpl");
$check = $_REQUEST['check'];
if (isset($check)) {
echo "<td width=\"490\" colspan=\"2\" valign=\"top\">";
$username = $_REQUEST["username"]; //_REQUEST for general
$password = $_POST["password"]; //_POST for security
$pass = md5($password); //Convert the user pass into a hash pass
$_SESSION['username'] = "$username";
$_SESSION['pass'] = "$pass";
include("./mysql.php"); //Connect to mySQL
$result = mysql_query("SELECT * FROM news_admin WHERE username='$username'");
$num = mysql_numrows($result);
if ($num < 1) {
echo "<p>Username doesnt exist</p>";
session_unset();
session_destroy();
}else{
$userinfo = mysql_fetch_array($result); // this is more helpful when you select more than just password in the future
if ($userinfo['password'] != $pass) {
echo "<p>Incorrect Password</p>";
session_unset();
session_destroy();
}else{
echo "<p>You are now logged in.<br />
<a href=\"./testy.php\">Click Here</a> to return Home.</p>";
}
}
mysql_close();
echo "</td></tr>";
}else{
include("./includes/login.tpl");
}
include("./includes/footer.tpl");
?>
testy.php
<?php
session_start();
print_r($_SESSION);
?>
print_r($_SESSIONS) is supposed to return an array with all my sessions in it, yet I get nothing. Whats going on?