Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 7th, 2002, 03:51 AM
lifeAfter76 lifeAfter76 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Memphis, TN
Posts: 20 lifeAfter76 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
password problems

Thank you for reviewing my question.

For some reason the query will fail if password('$password') is in it. Can anyone tell me what's going on? I am using php/mysql

function login($username, $password)
//check username and password with db
//if yes return true
//if no return false
//
{

//connect to db
$conn = db_connect();
if (!$conn)
return 0;

//check if username is unique
$result = mysql_query("select * from user where username = '$username' AND passwd = password('$password')");


if (!$result)
return 0;

if (mysql_num_rows($result)>0)
return 1;
else
return 0;
}

Reply With Quote
  #2  
Old October 7th, 2002, 10:11 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: password problems

Try echoing out the query and running it directly against the database. Tell us what error you get...

Reply With Quote
  #3  
Old October 7th, 2002, 11:02 PM
Carol Carol is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sunshine Coast Australia
Posts: 23 Carol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: password problems

I have had exactly the same problem as you. My code came out of a book "PHP and MySQL Web Development".

I am a complete ignoramus as you will see but with help from anon above, I've managed to make it work. What I don't know is whether the changes I've made will have security problems down the track. Someone can say if there might be a problem. Anyway, here is the code and it works:

// check if username is unique
$result = mysql_query("select * from admin where username ='$username' and password = '$password'");

I took out the ('$password') bit.

Hope this helps, let me know if I have done something bad.

Carol

Reply With Quote
  #4  
Old October 7th, 2002, 11:40 PM
lifeAfter76 lifeAfter76 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Memphis, TN
Posts: 20 lifeAfter76 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: password problems

I get a resource id #2 as the result

Reply With Quote
  #5  
Old October 8th, 2002, 12:43 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: password problems

Carol,

taking out the password bit is bad...anyone that can see your database can see all your passwords...

lifeafter76,

Make this:

$result = mysql_query("select * from user where username = '$username' AND passwd = password('$password')");

this:

$query = "select * from user where username = '$username' AND passwd = password('$password')";
echo $query;
$result = mysql_query($query);

Then you can see what is being sent to the database. Then, try and run that query against the database yourself without PHP and see what error you get.

Reply With Quote
  #6  
Old October 8th, 2002, 02:07 AM
lifeAfter76 lifeAfter76 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Memphis, TN
Posts: 20 lifeAfter76 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: password problems

It works! Thank you so much...so I take it that you should use mysql_query() on a variable as oppose to the actual query statement.

Reply With Quote
  #7  
Old October 8th, 2002, 03:52 AM
Carol Carol is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sunshine Coast Australia
Posts: 23 Carol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: password problems

I've tried your help anon and no go in terms of logging on. The select query prints out with the correct username and password showing.

Any more advice will be most welcome.

Thanks, Carol

Reply With Quote
  #8  
Old October 8th, 2002, 10:09 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: password problems

Carol,

And what happens when you try and run that query against the database, through PHPMyAdmin or something similar?

Reply With Quote
  #9  
Old October 8th, 2002, 08:59 PM
Carol Carol is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sunshine Coast Australia
Posts: 23 Carol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: password problems

I've never used PHPMyAdmin I must admit. In fact, I can't see how to use it. But I've run it through the MySQL Monitor as a normal sql query and it is perfect.

Thanks in anticipation.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > password problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek