Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 22nd, 2006, 5:47 PM   #1
SlickTheNick
Newbie
 
Join Date: Oct 2006
Posts: 4
Rep Power: 0 SlickTheNick is on a distinguished road
Odd problem with login script

I have a simple log in script that im making. I copied some code off of another login script that i made before (which works) but for some reason this one isnt working. Heres the code thats causing some problems:

[PHP]if($HTTP_POST_VARS['submit']){
$name = $HTTP_POST_VARS['name'];
$password = $HTTP_POST_VARS['password'];
$password = md5($password);

$sql1 = "SELECT * FROM users WHERE name='" . $name . "'";
$query = mysql_query($sql1);
$rows = mysql_fetch_array($query);

//username validator
if($rows['name'] == ''){
echo 'Username or password is incorrect.';

//password validator
}elseif($rows['password'] == $password){[/PHP]

It seems to be just the password validator that is the problem. When I take it out everything works fine, but as soon as i put it in it tells me that my password is incorrect even if i put the correct one in. Anyone know what the problem is?
SlickTheNick is offline   Reply With Quote
Old Oct 22nd, 2006, 6:36 PM   #2
matthewvb
Newbie
 
matthewvb's Avatar
 
Join Date: Sep 2006
Posts: 23
Rep Power: 0 matthewvb is on a distinguished road
Send a message via AIM to matthewvb
hum. i would verify the password in the db is md5.

try using just $_POST['variable'] to pull the info.

aside, the actual elseif looks good. you might run into problems if you pull multiple rows, but if name is a unique variable that you've checked for, that's all good.

try it out, let me know how it goes...might be with something else in the code below the verification.
__________________
matthewvb
www.matthewvb.com
matthewvb is offline   Reply With Quote
Old Oct 22nd, 2006, 6:40 PM   #3
SlickTheNick
Newbie
 
Join Date: Oct 2006
Posts: 4
Rep Power: 0 SlickTheNick is on a distinguished road
I thought that $HTTP_POST_VARS['variable']; was the exact same as $_POST?
SlickTheNick is offline   Reply With Quote
Old Oct 22nd, 2006, 7:16 PM   #4
elin
Newbie
 
Join Date: Oct 2006
Location: Melbourne
Posts: 1
Rep Power: 0 elin is on a distinguished road
Send a message via MSN to elin Send a message via Yahoo to elin
I guess you could print out the query, then copy and paste your query in the sql command line to see the result. That might help you immidiately spot the error. If still not, try to var_dump( $rows ) before if statement.

Btw, since PHP 4.1 the prefered variable is using $_POST and $_GET, and in PHP 5, the long predefined PHP arrays like $HTTP_POST_VARS you used might be disabled. If you can verify your PHP version, that might help as well.
elin is offline   Reply With Quote
Old Oct 22nd, 2006, 7:21 PM   #5
SlickTheNick
Newbie
 
Join Date: Oct 2006
Posts: 4
Rep Power: 0 SlickTheNick is on a distinguished road
Ok well I found the error and fixed it. There was a conflict with magic quotes
SlickTheNick is offline   Reply With Quote
Old Oct 22nd, 2006, 7:29 PM   #6
matthewvb
Newbie
 
matthewvb's Avatar
 
Join Date: Sep 2006
Posts: 23
Rep Power: 0 matthewvb is on a distinguished road
Send a message via AIM to matthewvb
glad you found it!
__________________
matthewvb
www.matthewvb.com
matthewvb is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
cgi/perl script + IE problem joyceshee Perl 2 Jan 24th, 2006 11:10 AM
PHP Script Timeout Problem kurifu PHP 12 Dec 5th, 2005 5:55 PM
Problem with Perl script eclipsed4utoo Perl 1 Dec 2nd, 2005 1:33 PM
Java script problem zeotrex JavaScript and Client-Side Browser Scripting 5 Sep 2nd, 2005 5:30 AM
php login script Brent PHP 14 Aug 5th, 2005 10:03 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:07 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC