8 Replies - 12305 Views - Last Post: 04 September 2012 - 04:52 AM Rate Topic: ****- 2 Votes

#1 kasirajan1681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-September 12

how to change password using php & mysql

Posted 03 September 2012 - 04:27 AM

:helpsmilie: i am searching for php+mysql coding to change the password. for eg,changing of password in mail.

This post has been edited by Dormilich: 03 September 2012 - 04:54 AM
Reason for edit:: not enough options for a Poll

Is This A Good Question/Topic? 0
  • +

Replies To: how to change password using php & mysql

#2 Mina-no-Hime  Icon User is offline

  • D.I.C Head

Reputation: 98
  • View blog
  • Posts: 176
  • Joined: 23-August 12

Re: how to change password using php & mysql

Posted 03 September 2012 - 04:28 AM

That's going to depend on what you're using as your user system -- each different system will store passwords in different ways. Can you be more specific? Are you using a pre-built Blog/CMS such as WordPress or Joomla, or is it a custom user system?
Was This Post Helpful? 0
  • +
  • -

#3 kasirajan1681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-September 12

Re: how to change password using php & mysql

Posted 03 September 2012 - 04:33 AM

ya i am using custom user system. and i am developing one web page and its having login option and if the user forgot the password means, they need to change the password by clicking in forgot password option. and if they give the correct old password and then after giving new password and confirm new password and after validation it needs to change the old password with the new one. This page must have validation too. . .
Was This Post Helpful? 0
  • +
  • -

#4 Mina-no-Hime  Icon User is offline

  • D.I.C Head

Reputation: 98
  • View blog
  • Posts: 176
  • Joined: 23-August 12

Re: how to change password using php & mysql

Posted 03 September 2012 - 04:37 AM

The standard way of doing it is to generate a unique key and send that to the user via email. Then, the user can enter their username and the key (usually this is done through the URL - take a look at any password reset email to see what I'm talking about) to enter the "password reset" page, in which they enter the password they want to change to.

The password change portion works in exactly the same manner as your registration page for storing the new password.
Was This Post Helpful? 1
  • +
  • -

#5 kasirajan1681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-September 12

Re: how to change password using php & mysql

Posted 03 September 2012 - 04:47 AM

ya, ok. but my task to do is, i need to get the count[number] of passwords in that usernames or userid's. and after getting that if the password matches the user name it need to change the old one with the new.and i need to do this by calling a function from another file such as updatepassword.php like that. now i am getting the user id from the user and if the user id matches the id in the database and then i make the program to update the password. but i need like the thing what i described above.
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2993
  • View blog
  • Posts: 10,343
  • Joined: 08-August 08

Re: how to change password using php & mysql

Posted 03 September 2012 - 04:57 AM

What you need is to show us how you're attempting this. We're not here to write code for you, but we'll help you find and fix errors in your code.
Was This Post Helpful? 1
  • +
  • -

#7 kasirajan1681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-September 12

Re: how to change password using php & mysql

Posted 03 September 2012 - 05:07 AM

ya fine. i too not asking you to write the code. i need reference to fix my problem. the coding is
<?php
include('config.php');//database connection
include('cust_pwdupdate.php');//update query in this page
$sql_obj=new cust_pwdupdate();//obj to access function
header("Content-Type: text/html; charset=UTF-8");  
extract($_POST);
$tablename='tblname';//tablename
$data=array();
$data['custid']=$custid;
$data['oldpwd']=$entered_old_password;
$data['newpwd']=$new_password;
$data['cfpwd']=$c_password;//confirm password
$data['tablename']=$tablename;
$update=$sql_obj->updateData($data); // sending posted data to validation
	if(!$update)
	{
		echo "false";
	}
	else
	{
		$_SESSION['user']['username']=$username;
		echo "password changed successfully";
	}
?>

and password update.php is
function updateData($data)
	{
		extract($data);
		$a=mysql_query("SELECT Password FROM tablename WHERE Custid='".$custid."' ");
		$res=mysql_fetch_array($a);
		$old_password=$res['Password'];
		if($old_password!=$entered_old_password)
		{
			$error	=	"Entered old password is inncorrect";
			$custid	=	$custid;
		} 
		elseif($new_password!=$c_password) 
		{
			$error	=	"New password & Confirm password are not same";
		} 
		else 
		{
			$updated	=	mysql_query("UPDATE tablename SET Password	=	'".$new_password."' WHERE Custid='".$custid."'");
		
			$update	=	mysql_affected_rows();
		
			if($update)
			{
				echo "You Have change the password successfully";
			}
			else
			{
				echo "password not changed";
			}
		}
	
	}


Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2993
  • View blog
  • Posts: 10,343
  • Joined: 08-August 08

Re: how to change password using php & mysql

Posted 03 September 2012 - 05:17 AM

You don't tell us what errors you're getting.

Why do you extract $_POST and then use the values to populate $data, then extract $data within the function? If you had simply passed $_POST your code would be easier to read and therefore easier to debug.
Was This Post Helpful? 2
  • +
  • -

#9 kasirajan1681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-September 12

Re: how to change password using php & mysql

Posted 04 September 2012 - 04:52 AM

ok. fine. i'll try this in my system and revert you as soon as possible...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1