Current location: Hot Scripts Forums » Programming Languages » PHP » password() not working


password() not working

Reply
  #1 (permalink)  
Old 10-12-09, 06:13 AM
karthikanov24 karthikanov24 is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
password() not working

hi
the PASSWORD( ) used in the following code, is used to take the newly added password from user to database

Code:
function addUser()
{
    $userName = $_POST['txtUserName'];
	$password = $_POST['txtPassword'];
		
	// check if the username is taken
	$sql = "SELECT user_name
	        FROM tbl_user
			WHERE user_name = '$userName'";
	$result = dbQuery($sql);
	
	if (dbNumRows($result) == 1) {
		header('Location: index.php?view=add&error=' . urlencode('Username already taken. Choose another one'));	
	} else {			
		$sql   = "INSERT INTO tbl_user (user_name, user_password, user_regdate)
		          VALUES ('$userName',PASSWORD('$password'), NOW())";
	
		dbQuery($sql);
		header('Location: index.php');	
	}
}
But here in the admin login code as follow,the PASSWORD( ) is not working. If a call is made to this funtion it shows error as:UNDEFINED FUNCTION PASSWORD( )
Code:
function doLogin()
{
	
	$userName = $_POST['txtUserName'];
	$password=PASSWORD($_POST['txtPassword']);
        
	
	// first, make sure the username & password are not empty
	if ($userName == '') {
		$errorMessage = 'You must enter your username';
	} else if ($password == '') {
		$errorMessage = 'You must enter the password';
	} else {
		// check the database and see if the username and password combo do match
		$sql = "SELECT user_id
		        FROM tbl_user 
				WHERE user_name = '$userName' AND user_password = '$password'";
				
		$result = dbQuery($sql);
what is the correct codes.....?


Thanks
karthikanov24
Reply With Quote
  #2 (permalink)  
Old 10-12-09, 03:35 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
PASSWORD is a MySQL function, you can't use it as a PHP function.

In the SQL that authenticates, you can use WHERE `password`=PASSWORD('$sPassword')
Reply With Quote
  #3 (permalink)  
Old 10-13-09, 12:04 AM
karthikanov24 karthikanov24 is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
still not working

hi
when i used replaced with your said codes,still its not working....
The login is done only when we type the password which are in form of hashes present in database.....



thanks
karthikanov24
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] changing password not working Beylah PHP 2 08-11-08 02:37 PM
Password Problems in VB6 iceiceady Visual Basic 6 03-28-06 03:17 PM


All times are GMT -5. The time now is 08:01 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.