Jump to content


Photo

Password function error in Mysql


  • Please log in to reply
5 replies to this topic

#1 natasha

natasha
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 24 March 2003 - 03:28 PM

hi all,
I am using PHP-MySql and use the following code for login authentication:

<?
$res=@mysql_query(\"select * from users where login=(\'$txtlogin\') and password=password(\'$txtpassword\')\");
?>

$txtlogin and $password are the text field names. The database has stored the password in the encrypted format. But still it i snot authenticating.
The connection to mysql etc is working. Without the encryption, the logn authentication works...what can be possibly wrong?
a very very perplexed
Natasha. :?:

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 24 March 2003 - 04:28 PM

Now if u have encoded the password

i.e if u have used ENCODE(str,pass_str) to store the password

then I guess have to \"DECODE\" them

Try using

DECODE(crypt_str,pass_str)

Hope this helps!
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 natasha

natasha
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 24 March 2003 - 04:42 PM

hi
Hmm.. this may sound silly to u..but I am pretty new to mysql. I hv just used the function password(string) to encrypt the password field in the database. and I just using \'password=password(\'$txtpassword\') as part of my query. It just refuses to authenticate..very maddening!
natasha

#4 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 24 March 2003 - 05:18 PM

Now when the passowrd is encrytpted

u have to do

select PASSWORD(\'$password_value\');

This will return a encrypted value and u have to compare this value.

I dont think u can decrypt the password vale that has been stored.

I hope this helps you.
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#5 natasha

natasha
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 24 March 2003 - 05:20 PM

yeah that is what I hv been doing the entire day today..will give it a shot tomorrow again!!
:lol:
Thanks a lot.

#6 Avalanche

Avalanche
  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts

Posted 01 April 2003 - 03:57 AM

Natasha, could you please stop stickying your posts unless it\'s really important? I noticed you did this on the PHP forums, too.

Thanks.
DEFINE("YOU","Spending Too Much Time On The Computer");




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users