weird php error - cannot explain just in title
discovered this forum a few days ago and still not into it enough to contribute - will happen soon i hope :)
right now i am experiencing something weird i hope someone can help me with.
In the following php code:
when i run it and enter a valid username and password, it wil开发者_C百科l always send me to failed.php although it should have returned a result.
When i add a random "echo" before the if clause, it goes into the correct branch, but of course can't do the header("Location..) any more.
Does anyone have an idea what i am missing here or why this is happening? Could it be some PHP setting i am not aware of?
thanks in advance Seb
(NOTE i know php4 is not up to date, sql injections etc. - i just want to know and maybe understand why this is happening ;) )
<?php
include("config.php");
$query = 'select * from users where username = "' .
$_POST['username'] . '" and password = "' .
md5($_POST['password']) . '"';
$select_user = mysql_query($query);
//echo "something";
if ($select_user && ($row = mysql_fetch_row($select_user)))
{
$user_id = $row[0];
session_start();
session_register('authorized');
$_SESSION['authorized'] = true;
$_SESSION['uid'] = $user_id;
//echo "anothersomething";
header("Location: portal.php");
exit;
}
else
{
$_SESSION['authorized'] = false;
$_SESSION['uid'] = 0;
header("Location: failed.php");
exit;
}
@MYSQL_CLOSE($db);
?>
精彩评论