forked from modi1231/DIC_Text_Based_Mafia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lost_Pass.php
86 lines (65 loc) · 2.05 KB
/
Lost_Pass.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
<?php include_once("connect.php"); ?>
<html >
<head>
<title>Test</title>
</head>
<body>
<?
if (isset($_POST['Send'])) {
$password = substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6);
// Generate a random password
$nsql = "SELECT * FROM login WHERE mail='".mysql_real_escape_string($_POST['Email'])."'";
$query = mysql_query($nsql) or die(mysql_error());
$row = mysql_fetch_object($query);
$name = htmlspecialchars($row->name);
$pass = htmlspecialchars($row->pass);
$mail = htmlspecialchars($row->email);
if((empty($_POST['Email']))){ // if the email field is empty there will be an error
echo 'You one field empty.';
}else{
if(empty($name)){ // there is no name with the entered email
echo 'Invalid information.';
}else{
if($_POST['Email'] != $mail){
echo 'Invalid information.'; // if their is no match in the email
}else{
if(!checkEmail($_POST['Email'])){ // the checkEmail function we have in our function that saves us time and sapce
echo 'Your email is not valid!';
}else{
$result = mysql_query("UPDATE users SET password='$password' WHERE name='" .mysql_real_escape_string($name). "'")
or die(mysql_error());
$to = $_POST['Email'];
$from = "[email protected]";
$subject = "Registration - Your Registration Details";
$message = "<html>
<body background=\"#4B4B4B\">
<h1>Game Registration Details</h1>
Dear $name, <br>
<center>
Your Username: $name <p>
Your Password: $password <p>
</body>
</html>";
$headers = "From: Game Lost Details <[email protected]>\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
echo 'We sent you an email with your Details!';
}
}
}// check if name is unused.
}// check if accepted to the tos.
}// name check.
// if post register.
?>
<form method="post" >
<center>
<h1><strong>Lost Password</strong></h1>
<p>Email:
<input type="text" name="Email" id="Email">
<br>
<input type="submit" name="Send" id="Send" value="Send">
</p>
</center>
</form>
</body>
</html>