forked from DarshanMaradiya/OnlineMusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforgotpassword.php
81 lines (73 loc) · 1.88 KB
/
forgotpassword.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
<!DOCTYPE HTML>
<html>
<head>
<title>Forgot Password</title>
<!-- <link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet'>
<link rel="stylesheet" type="text/css" href="css.css"> -->
</head>
<body>
<div class="wrapper">
<h1>FORGOT PASSWORD</h1>
<form action="forgotpassword.php" method="post">
<input class="email" placeholder="Email" type="email" name="email" pattern=".+@gmail.com" required>
<div>
<p class="email-help">Please enter your current email address.</p>
</div>
<!-- <input class="pass" placeholder="Password you remember" type="password" name="lastpass" required>
<div>
<p class="pass-help">Please enter the password you remember.</p>
</div> -->
<input class="submit" type="submit" name="submit" value="reset" required>
</form>
</div>
</body>
</html>
<?php
require('functions.php');
if(isset($_POST['submit']))
{
include('dbcon.php');
$email=$_POST['email'];
// $lastpass=md5($_POST['lastpass']);
$sql="SELECT * FROM `users` WHERE `email`='$email'";
$run=mysqli_query($con,$sql);
$row=mysqli_num_rows($run);
if($row==1)
{
$data = mysqli_fetch_assoc($run);
$otp = rand(100001, 999999);
$success = resetPasswordMail($data['id'], $data['email'], $data['name'], $otp);
if($success)
{
?>
<script>
alert('We have send a link to reset your password on your Email.\nLink is not yet temporarily active!!!!');
// window.open('index.php','_self');
</script>
<?php
session_start();
$uid = $data['id'];
$_SESSION['uid']=$uid;
$_SESSION['otp']=$otp;
header("Location: verifyotp.php");
}
else
{
?>
<script>
alert('Error Sending');
</script>
<?php
}
}
else
{
?>
<script>
alert('Email ID is incorrect !!\nEnter Again');
</script>
<?php
}
}
?>