For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > February 2008 > Re: [PHP-DB] Password decryption









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Password decryption
Daniel Brown

2008-02-17, 7:08 pm

On Feb 16, 2008 10:17 PM, Nasreen Laghari <nasreen_laghari@yahoo.com> wrote:
> Hi,
>
> I'm junior in PHP and stuck on Encryption.
>
> I have encrypted password using SQL :
>
> $query = "insert into user (userid,password,) values ('$username',Password('$pass'));";


It's a one-way encryption method, so you won't be able to see the
plain-text equivalent of the password again, but you can use this when
testing a login:

SELECT * FROM user WHERE userid='".$username."' AND
password=PASSWORD('".$pass."')";

Also, to correct your $query above, some things to note:
PASSWORD is a reserved word in MySQL, so you shouldn't name
any columns or databases as such.
You have a comma after `userid,password,` in your column bracket.
With PHP, you shouldn't end your MySQL query with a semicolon.
The code needs it to terminate the line, the query doesn't.

--
</Dan>

Daniel P. Brown
Senior Unix G
<? while(1) { $me = $mind--; sleep(86400); } ?>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com