Solved

Problems with password() server function

Posted on 2003-12-02
4
203 Views
Last Modified: 2008-03-06
Hi everyone,

I am creating a user registration and login forms.
During the user registration form I insert a record into my users table and encode my password with this method here is a snipet of my code:

$query = "INSERT INTO users (userID,userName, password, userType, irstName, lastName, phone, fax, email, website, gridArea, company, addedServices, specialty)  VALUES (NULL, '$userid', password('$userpassword'), '$userType', .......

The password field in MySQL database is a VarChar(10)

in my login form i will verify the user info and once again here is the snippet:

$query = "SELECT userType FROM $user_tablename WHERE userName = '$userid'                  AND password = password('$userpassword')";

THIS DOES NOT WORK, it does not seem to match the passwords. I have tried inserting an echo statement ensuring that the password passed by the variable is correct, I have echoed the whole query statement and it looks good.

I have tried inserting a user record without using the password method and then searching without of course using the password method and that seems to work. It is when I use the password method I am getting issues.

Could it my field size too small? or the wrong type?

Please help

Regards,
Chris

 
0
Comment
Question by:vinaymal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 100 total points
ID: 9862800
the field needs to be 16 chars in length, try then

loz
0
 
LVL 3

Expert Comment

by:ashoooo
ID: 9868309
password() function returns a string 16 chars in length... if you want to use the MD5() function, it returns a string 32 chars in length
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question