-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.php
158 lines (148 loc) · 4.29 KB
/
reset.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
include("navbar.php");
if (isset($_GET["resetValue"]))
{
$reset_value = $_GET["resetValue"];
$email= $_GET["username"];
$check_user = "SELECT * FROM user_register WHERE pss_reset = '$reset_value'";
$check_hos = "SELECT * FROM hospital_reg WHERE pss_reset = '$reset_value'";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style/login.css">
<script src="js/login.js"></script>
</head>
<body>
<?php
if (mysqli_query($conn,$check_user))
{
?>
<div class="container">
<!-- password error -->
<div class="mt-3 alert alert-danger alert-dismissible fade show" id="password_error" style="display: none;">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Password did not match</strong>
<!-- php password error -->
<?php
if (isset($_GET["error"]))
{
?>
<script>
passworderror();
</script>
<?php
}
?>
</div>
</div>
<div class="container">
<div class="row mt-5">
<div class="col-md-4 offset-md-4 pt-1 pb-1" id="set_text">
<span style="font-size: 30px;" >Set Password</span>
</div>
</div>
<div class="row">
<div class="col-md-4 offset-md-4 border-me">
<form action="" method="POST">
<label for="New Password">New Password</label>
<input type="password" id="password" name="password" class="form-control" required="true">
<label for="repassword">Re-Password</label>
<input type="password" class="form-control" onkeyup ="checkpass()" id="repassword" name="repassword" required="true">
<input type="hidden" value="<?php echo $email; ?>" name="username">
<input type="hidden" name="reset_value" value="<?php echo $reset_value; ?>">
<br>
<input type="submit" class="btn btn-outline-dark" value="Set Password" name="user_submit">
</form>
</div>
</div>
</div>
<?php
}
else if (mysqli_query($conn,$check_hos))
{
?>
<div class="container">
<div class="row mt-5">
<div class="col-md-4 offset-md-4 pt-1 pb-1" id="set_text">
<span style="font-size: 30px;" >Set Password</span>
</div>
</div>
<div class="row">
<div class="col-md-4 offset-md-4 border-me">
<form action="" method="POST">
<label for="New Password">New Password</label>
<input type="password" id="password" name="password" class="form-control" required="true">
<label for="repassword">Re-Password</label>
<input type="password" id="repassword" onkeyup="checkpass()" class="form-control" name="repassword" required="true">
<br>
<input type="submit" class="btn btn-outline-dark" value="Set Password" name="hos_submit">
</form>
</div>
</div>
</div>
<?php
}
else
{
echo "<script>window.location.href='index.php'</script>";
}
}
?>
<?php
// change user password
if (isset($_POST["user_submit"]))
{
$password = $_POST["password"];
$repassword = $_POST["repassword"];
$username = $_POST["username"];
$resetValue = $_POST["reset_value"];
if ($password==$repassword)
{
$md5pass = md5($password);
$sha1pass = sha1($md5pass);
$cryptpass = crypt($sha1pass,'pk');
$updt_user = "UPDATE user_register SET password = '$cryptpass' WHERE email = '$username'";
if (mysqli_query($conn,$updt_user))
{
echo "<script>window.location.href='login.php'</script>";
}
}
else
{
echo "<script>
window.location.href='reset.php?error=yes&username=$username&resetValue=$resetValue';
</script>";
}
}
?>
<!-- for hospital -->
<?php
if (isset($_POST["user_submit"]))
{
$password = $_POST["password"];
$repassword = $_POST["repassword"];
$username = $_POST["username"];
$resetValue = $_POST["reset_value"];
if ($password==$repassword)
{
$md5pass = md5($password);
$sha1pass = sha1($md5pass);
$cryptpass = crypt($sha1pass,'pk');
$updt_user = "UPDATE hospital_reg SET password = '$cryptpass' WHERE email = '$username'";
if (mysqli_query($conn,$updt_user))
{
echo "<script>window.location.href='login.php'</script>";
}
}
else
{
echo "<script>
window.location.href='reset.php?error=yes&username=$username&resetValue=$resetValue';
</script>";
}
}
?>
</body>
</html>