-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrp.php
34 lines (30 loc) · 832 Bytes
/
rp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
session_start();
$dbservername = 'localhost';//or localhost
$dbname = 'project'; // your db_name
$dbusername = 'root'; // root by default for localhost
$dbpassword = ''; // by defualt empty for localhost
//delete details
$pass=$_POST["pass"];
$user="";
if(isset($_SESSION["otp"]))
{
$user=$_SESSION["otp"];
}
$_SESSION["newpass"]="";
$_SESSION["otp"]="";
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE users SET password='".$pass."' WHERE username='".$user."'";
if ($conn->query($sql) === TRUE)
{
$_SESSION["passchange"]="s";
header("location:index.php");
} else
{
echo "<script>alert('Failed to change Password');</script>";
}
$conn->close();
?>