Cara mengubah kata sandi login di PHP

Cara mengubah kata sandi login di PHP

Cara mengubah kata sandi login di PHP

Cara mengubah kata sandi login di PHP, skrip yang wajib kita buat saat membuat sebuah aplikasi PHP yaitu fitur ganti password nah kami akan tunjukkan skrip sederhana dari ganti password yang bias anda modifikasi sendiri nantinya, berikut contohnya :

<?php

session_start();

$user = $_SESSION["user"]; //parameter buat ganti password

$con = mysqli_connect(localhost,'root','',crud) or die('Unable To connect');

if(count($_POST)>0) {

$result = mysqli_query($con,"SELECT *from users WHERE username='" . $id . "'");

$row=mysqli_fetch_array($result);

if($_POST["currentPassword"] == $row["password"] && $_POST["newPassword"] == $row["confirmPassword"] ) {

mysqli_query($con,"UPDATE student set password='" . $_POST["newPassword"] . "' WHERE name='" . $id . "'");

$message = "Password Changed Sucessfully";

} else{
$message = "Password is not correct";

}

}

?>

<!DOCTYPE html>

<html>

<head>

<title>Password Change</title>

</head>

<body>

<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>

<br>

New Password:<br>

<input type="password" name="newPassword"><span id="newPassword" class="required"></span>

<br>

Confirm Password:<br>

<input type="password" name="confirmPassword"><span id="confirmPassword" class="required"></span>

<br><br>

<input type="submit">

</form>

<br>=

<br>

</body>

</html>

 

Tinggalkan Komentar

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

Need Help? Chat with us