/    Sign up×
Community /Pin to ProfileBookmark

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
}
}
[/code]

Notes::
the login query out puts the following::
SELECT * FROM `users` WHERE `user_username` = ‘administrator’ AND `user_password` = ‘4cb9c8a8048fd02294477fcb1a41191a’;

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>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@pyroApr 22.2005 — Try this:

[code=php]if(mysql_num_rows($login_sql_result) == 0) {[/code]
Copy linkTweet thisAlerts:
@GenixdeaeauthorApr 22.2005 — nope same thing...if you want to test it, go [URL=http://sprague.wvi.com/students05/phelan_dustin/calendar/index.php?type=login]here[/URL]

username is administrator

password is changeme(which you can't change yet lol)
Copy linkTweet thisAlerts:
@GenixdeaeauthorApr 22.2005 — Figured it out. Turns out in the db the password was litteraly
[code=php]". md5("changeme") ."[/code] not the hashed version of the password ?

i am curious about how/why phpmyadmin still was able to run the query correct tho
×

Success!

Help @Genixdeae spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...