Solved

Problems with password() server function

Posted on 2003-12-02
4
201 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
php subtract from date 2 26
Generate PDF's using TCPDF - Initial Set Up 9 29
HTTPS for signup & login - HTTP for all other pages 10 43
deprecated mysql extensions 1 22
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

735 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