Change Password in PHP

In PHP, Change Password Code: Please find below the php code with the help of html.

<?php

$connect=mysql_connect(“servername”,”username”,”password”); OR die (“connection failed”);
$db=mysql_select_db(“user_database“,$connect);

if(isset($_POST[‘submit‘]))
{
$current_pswd=$_POST[‘current‘];
$new_pswd=$_POST[‘newpass‘];
$confirm_pswd=$_POST[‘confirm‘];

if($current_pswd==$password)
{
if($new_pswd == $confirm_pswd)
{
$sql=mysql_query(“UPDATE users SET password=’ “.$new_pswd.” ‘ WHERE id=’2’ “);

if($sql)
{
echo “Password has been changed Successfully…….”;
}
else
{
echo “Try again……”;
}
}
else
{
echo “Password does not match to the New Password….”;
}
}
else
{
echo “Current Password is not correct….”;
}
}

?>

<form action=” ” method=”post“>
<input type=”passwordname=”currentplaceholder=”Current Password>
<input type=”passwordname=”newplaceholder=”New Password>
<input type=”passwordname=”confirmplaceholder=”Confirm New Password>

<input type=”submitname=”submitvalue=”Click Here>
</form>


onTime It Solution

onTime IT Solution always happy to serve you in Information Technology (IT). Learn HTML, CSS, Javascript, PHP, Android, Digital Marketing, Latest IT News and many more.

Leave a Reply

Your email address will not be published. Required fields are marked *