Solved

Problems with password() server function

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now