-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforgotpass.php
127 lines (122 loc) · 4.76 KB
/
forgotpass.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
session_start();
?>
<?php
if(($_SERVER["REQUEST_METHOD"] == "POST") && isset($_POST["cpass"])) {
$server_name = "localhost";
$user_name = "root";
$password = "";
$db_name = "mentoring_application";
$pass = $_POST["cpass"];
$unm = $_SESSION['uname'];
$mail = $_SESSION["mail"];
function role($text) {
preg_match_all("/@[\._a-zA-Z0-9-]+/i",$text,$matches);
return $matches[0];
}
$role = role($mail);
$conn = mysqli_connect($server_name, $user_name, $password, $db_name);
if(!$conn) {
die("Connection Failed: ".mysqli_connect_error());
}
else {
if($role[0] == "@marwadiuniversity.ac.in") {
$upd = "UPDATE mentee_details SET password = '$pass' WHERE first_name = '$unm'";
// echo $upd;
$exe = $conn->query($upd);
}
else if($role[0] == "@marwadieducation.edu.in") {
$upd = "UPDATE mentor_details SET password = '$pass' WHERE first_name = '$unm'";
// echo $upd;
$exe = $conn->query($upd);
}
else {
$upd = "UPDATE parent_details SET password = '$pass' WHERE first_name = '$unm'";
// echo $upd;
$exe = $conn->query($upd);
}
}
}
if(($_SERVER["REQUEST_METHOD"] == "POST") && isset($_POST["passcode"])) {
if($_POST['passcode'] == $_SESSION['tempcode']) {
?>
<!DOCTYPE html>
<html>
<head>
<title>Create Password!</title>
</head>
<body>
<div>
<form action="./forgotpass.php" method="post">
<table>
<tr>
<td>
<input type="password" name="pass" id="pass" placeholder="Password"
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}"
title="Password must contain: at least one number, at least one uppercase and lowercase letter, at least 8 or more character" required>
</td>
</tr>
<tr>
<td>
<input type="password" name="cpass" id="cpass" placeholder="Confirm Password" required oninput="check(this)">
<script>
function check(inp) {
if(inp.value != document.getElementById("pass").value) {
inp.setCustomValidity("Password must be match!!");
} else {
inp.setCustomValidity("");
}
}
</script>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Reset" id="">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php
} else {
echo "NOT SAME";
}
} else {
?>
<!DOCTYPE html>
<html>
<head>
<title>Forgot Password!</title>
</head>
<body>
<div>
<form action="./php/forpass.php" method="post">
<table>
<tr>
<td>
<input type="text" name="email" id="" placeholder="Email ID" title="" oninput="checkmail(this)" required>
<script>
function checkmail(mail) {
if(!((mail.value).match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/))) {
mail.setCustomValidity("Email ID format must be match!!");
} else {
mail.setCustomValidity("");
}
}
</script>
</td>
<td>
<input type="submit" value="Reset" id="">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php
}
?>