-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatepwd.php
72 lines (60 loc) · 2.69 KB
/
updatepwd.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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Brick ball</title>
<meta name="keywords" content="brick ball update password page">
<meta name="description"
content="breakout game for web browser update password page">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="images/brickball-icon.png">
<link rel="stylesheet" type="text/css" href="css/brickball.css">
</head>
<body>
<div id="container">
<header>
<h1><a class="heading" href="brickball.php">brick ball</a></h1>
</header>
<?php
$servername = "localhost";
$username = "adpfrank_7ba6_cg";
$password = "gosun";
$dbname = "adpfrank_db1";
$token = $_GET['token'];
$email = $_GET['email'];
$now = time();
try {
$conn = new PDO("mysql:host=$servername;dbname=adpfrank_db1", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// sql to select the users expiration
$sql = $conn->prepare("SELECT expiration FROM members WHERE token='" .
$token . "' AND email='" . $email . "'");
$sql->execute();
$column = $sql->fetch(PDO::FETCH_ASSOC);
// check to see if token expired, if not show the form
if ($now < $column['expiration']) {
echo '<div class="form-response"><h2>Reset Password</h2>' .
'<form class="tryagain" action="resetpwd.php" method="post">' .
'<fieldset><input type="hidden" name="email" value="' .
$email . '" required><label><b>New Password:</b></label>' .
'<input type="password" placeholder="Enter New Password" name=' .
'"newpsw" maxlength="20" required>' .
'<label><b>Confirm New Password:</b></label><input type=' .
'"password" placeholder="Enter New Password" name=' .
'"newpsw-confirm" maxlength="20" required><div class="clearfix">' .
'<button type="submit">Submit</button></div></fieldset></form></div>';
} else {echo '<div class="form-response">The time alloted to reset' .
' your password has passed.' .
' Please, try again.<br /><br /><h2>Forgot Password</h2><form class="tryagain" action="maillink.php" method="post" autocomplete="on"><fieldset><label><b>Email:</b></label><input type="email" placeholder="Enter Email Address" name="email" maxlength="255" required><div class="clearfix"><button type="submit">Next</button></div></fieldset></form></div>';}
} catch (PDOException $e) {
echo '<p class="form-response"><span class="errormsg">' .
'Oopsy Daisy! Error: ' . $e->getMessage() .
'</span><br /><a class="error-link" href=' .
'"brickball.php">Please, try again</a>.</p>';
}
$conn = null;
?>
</div>
</body>
</html>