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
Solved

Problems with password() server function

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 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