Ask Question


How to change login password in PHP

$name = $_SESSION["name"];
$con = mysqli_connect('','root','','admin') or die('Unable To connect');
if(count($_POST)>0) {
$result = mysqli_query($con,"SELECT *from student WHERE name='" . $name . "'");
if($_POST["currentPassword"] == $row["password"]) {
mysqli_query($con,"UPDATE student set password='" . $_POST["newPassword"] . "' WHERE name='" . $name . "'");
$message = "Password Changed Sucessfully";
} else $message = "Current Password is not correct";
<!DOCTYPE html>
<title>Password Change</title>
<h3 align="center">CHANGE PASSWORD</h3>
<div><?php if(isset($message)) { echo $message; } ?></div>
<form method="post" action="" align="center">
Current Password:<br>
<input type="password" name="currentPassword"><span id="currentPassword" class="required"></span>
New Password:<br>
<input type="password" name="newPassword"><span id="newPassword" class="required"></span>
Confirm Password:<br>
<input type="password" name="confirmPassword"><span id="confirmPassword" class="required"></span>
<input type="submit">

Subscribe with us to get latest topic update

Choose a Language