Dear Fellow Coders,
I'm having a very dumb problem that you will probably be able to answer in two seconds and I will smack my self for it later. But anyways here goes.
My problem is that I for some reason or another can not get $authorized variable in logging.php file to get it's setting from the session. I have checked my php.ini and I have even turned Register Globals on just to see if that was affecting it and that didn't seem to make a difference.
When I look at the session file it does show that "yes" is set. Just so no one thinks that maybe it's because the session isn't actually registering the information.
// logging.php file
$authorized = $_SESSION["yes"];
if(!isset($authorized)){
header("Location: http://localhost/index.php");
exit;
}
function login($username,$password) {
//Check to see if $username already contains info
if (isset($username)) {
//If non-empty check the database for matches
//connect to MySQL
$conn = mysql_connect("localhost", "root", "") or die("Unable to connect to database.");
//Select database on MySQL Server
$db = mysql_select_db("test") or die("Unable to select database.");
//Formulate the query
$sql = "SELECT * FROM mts_users WHERE username='$username' and password='$password'";
//Execute the query and put results in $result
$result = mysql_query($sql);
//Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($result);
//------>This is where I specify authorized and attempt to set it. which seems to work.
if ($num != "0") {
$authorized = "yes";
session_start();
session_register($authorized);
header("Location: http://localhost/logging.php");
exit;
} else {
echo "I'm sorry but the username and password combination that you used was incorrect please try again useing your browsers back button.";
exit;
}
}
}