Hi everyone,

I have an Login page where the Admin enters his username and password and enter his, After he has enter into his page, there is a option for him to change his password..

Enter Current password:
Enter new password:
Confirm new password:

Confirm >>

When he clicks the confirm button the password gets updated..
How do we update the password in mysql.
Whats the php code to update the password.

Pls help..
Thanks..

first check current password using select query. if match current password with db value update that particular password with new password using update query in mysql.

Respected sir;
I need a code of this update password script,
please give me
Thanks & regards
zahid

have you a code sir of update password?

Just a technique. Replace variables with form's variable and Update Query according to your table structure

<?php
$pass = $_POST['password'];
$rpass = $_POST['repeatpassword'];
if($pass==$rpass){
	$query = "UPDATE QUERY HERE";
	mysql_query($query);
}

?>

thanks evstevemd

thanks evstevemd

Karibu (Welcome)

Just a technique. Replace variables with form's variable and Update Query according to your table structure

<?php
if($_POST['btn']=='Update'){

$old_pass=$_POST['opass'];

$new_pass=$_POST['npass'];

$query="UPDATE users set password='$new_pass' where password='$old_pass'";
mysql_query($query);
?>

is it write sir?

<?php
if($_POST['btn']=='Update'){
$old_pass=$_POST['opass'];
$new_pass=$_POST['npass'];
if($old_pass==$$new_pass){
$query="UPDATE users set password='$new_pass' where password='$old_pass'";
mysql_query($query);

}
else{
echo "Password Doesn't match!!";
}


?>

first check current password using select query. if match current password with db value update that particular password with new password using update query in mysql.

hi thr,

Could u pls tell me how to write the codes..
I tried it out but cant get it updated... in the admin table..
Pls help...
Thanks

hi thr,

Could u pls tell me how to write the codes..
I tried it out but cant get it updated... in the admin table..
Pls help...
Thanks

Did you try the above trick

When using passwords, make sure you encrypt it. Saving raw passwords is not only bad practice, it's wrong. An extra security measure would be to encrypt the password before sending it VIA POST. This is easily done by using javascript, you never want to submit the raw password.

Just some advice to add a little security.

i need help for my project..

we are taskesd to create a website yet i don't have codes for the LOG IN button
can please give me ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.