Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Apr 2003
Posts: 6
Lurker
Lurker
Offline
Joined: Apr 2003
Posts: 6
I have a simple PHP login script that checks username and password in a table called 'user' in a database called 'secret'.

The PHP script is checking as such:
$db = mysql_connect("localhost", "myuser", "mypassword");
mysql_select_db("secret")
SELECT id from user WHERE username = '$user' AND password = MD5('$pass');

$user and $pass are simply the value from the login. THe above SQL query is presenting a empty set for #user and $pass, but does return the id.

So my questions is, how do I add a MD5 password to the password field ( $pass ) for the $user ?

I've tried: SELECT MD5('mypasswordhere'); and this does spit out a MD5 encrypted password for 'mypasswordhere' but how do I get it in the password field?

michael

Sponsored Links
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
[]how do I add a MD5 password to the password field ( $pass ) for the $user ?[/]

I don't understand this question.

Joined: Apr 2003
Posts: 6
Lurker
Lurker
Offline
Joined: Apr 2003
Posts: 6
what would be the syntax to compare the MD5 encrypted password in the database against a mysql_fetch_row statemnt query such that is it existed would do x.

michael

Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
Do you mean that you want to fetch the MD5-encrypted password from the database, and then compare it to something else, using PHP?

Maybe it would help if you write some pseudo-code, and then I can translate it to valid PHP or SQL.

Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
I think what you need to do is to md5 the password with php and just store it in the field. This way you will have a simple comparison of two values.

So if you have a text box which is of type password (displays little stars) you grab that value and you do:

$encrypted = md5($pass);

and then

SELECT id from user WHERE username = '$user' AND password = '$encrypted';

This should do what you want. Alternatively if I am totally wrong on understanding what you need (no big surprise there ) please let us know what you were thinking with a bit more detail.


Nikos
Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,583
Posts293,955
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 13812
Topics Created 0
Posts Made 0
Users Online 1
Birthdays 12
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20260108)