Ok i’ve made ton of these, and odds are the problem is simple. Anyways i’ve got a login script that when ran in PHP My Admin, works fine, but when ran in the website it brings up the error that i told it to if it retrieved no records.
here’s the code
[code=php]$login_sql_query = “SELECT * FROM `”. USERS_TABLE .”` WHERE `user_username` = ‘”. $_POST[“username”] .”‘ AND `user_password` = ‘”. md5($_POST[“password”]) .”‘;”;
$login_sql_result = mysql_query($login_sql_query, DBCONN);
if(!mysql_num_rows($login_sql_result)) {
echo “The user information you have entered is incorrect. Please go back and try again.”;
echo $login_sql_query;
}else{
$update_user_info = “UPDATE `”. USERS_TABLE .”` SET `user_last_logon` = NOW() WHERE `user_username` = ‘”. $_POST[“username”] .”‘ AND `user_password` = ‘”. md5($_POST[“password”]) .”‘;”;
$update_user_execute = mysql_query($update_user_info, DBCONN);
while($user_info = mysql_fetch_assoc($login_sql_result)) {
$_SESSION[“logged”] = “1”;
$_SESSION[“username”] = $user_info[“user_username”];
$_SESSION[“acs_lvl”] = $user_info[“user_acs_lvl”];
$_SESSION[“id”] = $user_info[“ID”];
?>
<meta http-equiv=”refresh” content=”1;index.php?calid=<?PHP echo $_GET[“calid”]; ?>” />
You have successfully logged in. If you are not redirected please click <a href=”index.php?calid=<?PHP echo $_GET[“calid”]; ?>”>here</a>.
<?PHP
}
}
Notes::
the login query out puts the following::
SELECT * FROM `users`user_username`user_password
it works and executes fine in PHPMyAdmin but in the web interface it brings up the error:: echo “The user information you have entered is incorrect. Please go back and try again.”;
the password is changeme, so decrypting the md5 wont do ya ne good lol.
if i remove the ! from if(!mysql_num_rows()){ then nothing gets out putted, when i view the page source it just displays: <html><body></body></html>