-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresetPassword.php
95 lines (78 loc) · 2.34 KB
/
resetPassword.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<!-- <head>
<link rel="stylesheet" href="styleproflogin.css">
</head> -->
<body>
<?php
session_start();
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$pass=test_input($_POST["password"]);
$conpass=test_input($_POST["conpassword"]);
$email=$_SESSION['email'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "classroom";
$upd=0;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if($pass!=$conpass){
echo"Both Passwords don't match.";
}else if($pass==$conpass){
$sql1="SELECT email FROM professors WHERE email='$email'";
$res=$conn->query($sql1);
// $conn->close();
if($res->num_rows==0){
echo"";
}else{
$sql4="UPDATE professors SET password ='$pass' WHERE email='$email'";
$res=$conn->query($sql4);
$upd=1;
// header("Location: indexLogin.php");
}
// }else if($usertype=="student"){
// $sql2="SELECT email FROM students WHERE email='$email'";
// $res=$conn->query($sql2);
// if($res->num_rows==0){
// echo"";
// }else{
// $sql3="UPDATE students SET password ='$pass' WHERE email='$email'";
// $res=$conn->query($sql3);
// $upd=1;
// // header("Location: indexLogin.php");
// }
}
$conn->close();
}
?>
<div class="loginfrm">
<form method="post" class="form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<h2 class="title">RESET PASSWORD</h2>
<div class="ind">
<input type="password" name="password" class="input">
<label for="password" class="label">Password:</label>
</div>
<div class="ind">
<input type="password" name="conpassword" class="input">
<label for="conpassword" class="label">Confirm Password:</label>
</div>
<div class="butn">
<input class="btn" type="submit" name="click" value="Reset Password">
<?php if(isset($_POST['click'])){echo"<button><a href='index.php'>Login</a></button>";} ?>
</div>
</form>
<br>
</div>
</body>
</html>