-
Notifications
You must be signed in to change notification settings - Fork 0
/
verifytoken.php
52 lines (50 loc) · 2.05 KB
/
verifytoken.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
<?php include ('includes/connection.php'); ?>
<?php include 'includes/header.php';?>
<?php include 'includes/navbar.php';?>
<?php
if (!empty($_GET['token'])) {
$token = mysqli_real_escape_string($conn , $_GET['token']);
$query = "SELECT token FROM users WHERE token = '$token' ";
$run = mysqli_query($conn , $query) or die(mysqli_error($conn));
if (mysqli_num_rows($run) > 0) {
?>
<div class="login-card">
<h1>Change Password</h1><br>
<form action = "" method="POST">
<input type="password" name="password" placeholder="Enter New Password" required="">
<input type="password" name="repassword" placeholder="Confirm New Password" required="">
<input type="submit" name="change" class="login login-submit" value="submit">
</form>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js'></script>
<?php
if (isset($_POST['change'])) {
$password = mysqli_real_escape_string($conn , $_POST['password']);
$repassword = mysqli_real_escape_string($conn , $_POST['repassword']);
if (strlen($password) < 6 ) {
echo "<center> <font color = 'red' > Password should be atleast 6 characters long !</font><center> ";
}
else if ($password == $repassword) {
$newpassword = password_hash("$password" , PASSWORD_DEFAULT);
$query1 = "UPDATE users SET token = '' , password = '$newpassword' WHERE token = '$token' ";
$run = mysqli_query($conn , $query1) or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "<center> <font color = 'green' > Password Changed Successfully </font><center> " . " " . "<a href='login.php'>login</a>" ;
}
else {
echo "<center> <font color = 'red' > Error Occured !</font><center> " ;
}
}
else {
echo "<center> <font color = 'red' > Passwords do not match</font><center> " ;
}
}
}
else {
echo "something went wrong " . " <a href=recoverpassword.php> Try again </a> ";
}
}
else {
header("location: index.php");
}
?>