Hi there,
I wonder if u guys can help me out. I have an authentication script which checks for auth. If auth is okay it redirects to the supposed page. If auth is not okay then it will redirect to an error page.
Heres what happens in 4.3.1 and 4.2.6 versions the script seen below works fine. However my webhost has 4.0.6. What happens there is that the script does not redirect when auth is okay yet it redirect when auth is not okay. Whats even funnier is that when auth is okay and it doesnt redirect it still enters the data into the userlog as if you have logged in.
My question is ...looking at the code is there anything i can change to solve this problem with my hosts environment. I tried echoing javascript and meta refresh still wont work. I dont get it how can it semi-work !!. Once i log in and it doesnt redirect. I can manually type the "authenticated page" and i can view everything. Which means that UID is registered yet it wont redirect !. Can any one lend a hand here ? and can someone explain why 4.0.6 doesnt support this code ?
Thank u !
Heres the code:
<?
session_start();
ob_start();
$sid = session_id();
if (session_is_registered("uid")) {
header("Location: intro.php?$sid");
exit();
}else{
$login = "
login page
";
echo $login;
if ($op == "ds"){
$db_name = "db";
$table_name = "members";
// Connection .....
//$db ....
$sql = "SELECT * FROM $table_name
WHERE username = \"$username\" AND password = \"$password\"
";
$result = mysql_query($sql)
or die ("Can't execute query.");
$num = mysql_numrows($result);
if ($num != 0) {
$sql = "SELECT * FROM $table_name
WHERE username = \"$username\" AND password = \"$password\"
";
$result = mysql_query($sql)
or die ("Can't execute query.");
while ($row = mysql_fetch_array($result)) {
$uid = $row['uid'];
$fname = $row['firstname'];
$lname = $row['lastname'];
session_register('uid');
$result = mysql_query($sql)
or die ("Can't enter users log.");
header("Location: intro.php?$sid");
exit();
}
}else{
header("Location: error.php?$sid");
exit();
}
}
}
?>