NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Back to the sign in problem

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-12-2005, 03:33 PM THREAD STARTER               #1 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




Back to the sign in problem


Encountered the MySQL problem again. My whole login form is screwed and I cannot cope with it anymore. Help is apreciated very much.

PHP Code:
<?php 
session_start
();


include(
"config.php"); 
????: NamePros.com http://www.namepros.com/programming/123167-back-to-the-sign-in-problem.html

$passwordbeforemd5=$_POST['password'];
????: NamePros.com http://www.namepros.com/showthread.php?t=123167

$username=$_POST['username'];
$password=md5('$passwordbeforemd5');

$query "SELECT * FROM users WHERE username='$username' AND password='$password'" or die(mysql_error());
$id mysql_result($query,0,"id");
$account mysql_result($query,0,"account");


//$username=!isset($_SESSION['username'];
//$password=!isset($_SESSION['password'];

// Registering the variables uname and pwd
session_register("username","password","id""account");

//Check user exists in database
$sql mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");

//Using mysql_num_rows we count the number of rows matching username and password which should be 1 if true and 0 if false
$login_check mysql_num_rows($sql);

if (
$login_check == "1") {
$_SESSION['logged_in'] = true;
include (
"membersarea.php");
}
else {
include(
"head.php");
session_unset();
echo 
"<h1>Error</h1><p>Your attempt at logging in failed. If you feel as if there is
a problem, email the administrator at admin@darkfx.co.uk or use the contact form</p>"
;
include(
"foot.php");
}



?>

That's my whole sign in verification script. Obviously a form gets posted to this script with two text fields 'username' and 'password'. I cannot login. Or when I can, it lets me log in with any password. It's very screwed up but this is my last resort. If you guys cannot help me, I'm packing the whole thing in....Thanks
Encenta.com is offline  
Old 09-12-2005, 03:52 PM   #2 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



What is the mySQL error that is being displayed?

-Bob
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Old 09-12-2005, 04:03 PM THREAD STARTER               #3 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




Well, it displays :

PHP Code:
Warningmysql_result(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/darkfx.co.uk/httpdocs/studios/xsignin.php on line 13
????: NamePros.com http://www.namepros.com/showthread.php?t=123167

Warning
mysql_result(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/darkfx.co.uk/httpdocs/studios/xsignin.php on line 14 
But I can also log in with any password as long as the username is within the database. Sorry for being grumpy - very bad day
Encenta.com is offline  
Old 09-12-2005, 04:17 PM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Kinda in a rush but I think this will work..

PHP Code:
<?php
session_start
();


include(
"config.php");

$passwordbeforemd5 $_POST['password'];

$username $_POST['username'];
$password md5('$passwordbeforemd5');

$query mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1") or die(mysql_error());
$id mysql_query($query0"id");
$account mysql_query($query0"account");


//$username=!isset($_SESSION['username'];
//$password=!isset($_SESSION['password'];

// Registering the variables uname and pwd
session_register("username""password""id""account");

//Check user exists in database
$sql mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1");

//Using mysql_num_rows we count the number of rows matching username and password which should be 1 if true and 0 if false
$login_check mysql_num_rows($sql);

if (
$login_check == "1") {
????: NamePros.com http://www.namepros.com/showthread.php?t=123167
$_SESSION['logged_in'] = true;
include (
"membersarea.php");
}
else {
include(
"head.php");
session_unset();
echo 
"<h1>Error</h1><p>Your attempt at logging in failed. If you feel as if there is
a problem, email the administrator at admin@darkfx.co.uk or use the contact form</p>"
;
????: NamePros.com http://www.namepros.com/showthread.php?t=123167
include(
"foot.php");
}

?>
Last edited by SecondVersion; 09-12-2005 at 04:22 PM.
Eric is offline  
Old 09-12-2005, 04:22 PM THREAD STARTER               #5 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




Thanks for the help but no change
Encenta.com is offline  
Old 09-12-2005, 06:04 PM   #6 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



Again, I think you forgot the mysql_query when you defined $query. Try changing this:

PHP Code:
$query "SELECT * FROM users WHERE username='$username' AND password='$password'" or die(mysql_error());
$id mysql_result($query,0,"id");
$account mysql_result($query,0,"account"); 
To this:

PHP Code:
$query mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'") or die(mysql_error());
$id mysql_result($query,0,"id");
????: NamePros.com http://www.namepros.com/showthread.php?t=123167
$account mysql_result($query,0,"account"); 
-Bob
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Old 09-13-2005, 09:02 AM THREAD STARTER               #7 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




I did try that but I must've changed it back. This prevents the PHP error but I am still able to log in with any password
Encenta.com is offline  
Old 09-13-2005, 01:23 PM   #8 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



Hmmm, tough but interesting one. Would you like me to have a look at it for you? I am good with troubleshooting. All I'd need is ftp access.

-Bob
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Old 09-13-2005, 02:24 PM THREAD STARTER               #9 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




That would be brilliant. I'm just trying to fixup an FTP account which is proving difficult
__________________
Encenta - Amazon Associates CMS
Encenta.com is offline  
Old 09-15-2005, 10:10 AM   #10 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



After playing around with it, the problem lies here (I should have seen this in the beginning):

PHP Code:
$password=md5('$passwordbeforemd5'); 

the md5 function takes a string as a parameter. You have passed it a parameter, but you have enclosed it in single quotes. When you enclose a variable in single quotes, the variable is NOT interpolated. All you have to do is change the single quotes to double quotes and it works (which I did in your script).

So in essence what was happening is that the md5() function was performing its duty on the string '$passwordbeforemd5' ALL THE TIME, and NOT what the user had entered in the password form field. This led to the SAME $password variable EVERY time.
????: NamePros.com http://www.namepros.com/showthread.php?t=123167

You will need to reset the password for the specified user to whatever you want it to be, then all should work.

PM / reply if you have additional questions.

-Bob
__________________
Can't wait to be out of this forsaken business. Getting close! :)
Last edited by moondog; 09-15-2005 at 10:16 AM.
moondog is offline  
Old 09-16-2005, 07:11 AM THREAD STARTER               #11 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




woAh. I cannot thank you enough!

Reputation boosted! NP $'s Donated (bit tight though, sorry)!

__________________
Encenta - Amazon Associates CMS
Encenta.com is offline  
Old 09-16-2005, 12:16 PM   #12 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



Originally Posted by miseria
woAh. I cannot thank you enough!

Reputation boosted! NP $'s Donated (bit tight though, sorry)!

Welcome and no worries on the NP$. Glad I could help.
????: NamePros.com http://www.namepros.com/showthread.php?t=123167

Happy coding.

-Bob
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Closed Thread


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Back Button problem after log out HELP! 3rulzs Programming 2 05-17-2004 07:55 AM
Howto: Protect your site from BACK BUTTON TRAPS Mp)Tarh Webmaster Tutorials 0 08-10-2003 01:13 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 03:16 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger