-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforget.php
More file actions
82 lines (73 loc) · 2.01 KB
/
forget.php
File metadata and controls
82 lines (73 loc) · 2.01 KB
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
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Password Recovery </title>
</head>
<body style="background-color:skyblue">
<hr />
<center> <h2> Recover Password </h2> </center>
<hr />
<center>
<form #action="details.php" method = "post">
<br />
<table>
<tr>
<td><br />Old Password       </td>
<td><br /><input type="name" name="opwd" />            </td>
</tr>
<tr>
<td><br />New Password       </td>
<td><br /><input type="password" name="npwd" />            </td>
</tr>
<tr>
<td><br />Rewrite New Password       </td>
<td><br /><input type="password" name="rnpwd" />            </td>
</tr>
</table>
<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
die("Connection Failed");
}
if(!(mysql_select_db("medical_inventory", $con)))
{
die ("Database Not Selected");
}
if(isset($_POST['opwd']) && isset($_POST['npwd']) && isset($_POST['rnpwd']))
{
$opd = $_POST['opwd'];
$query = "SELECT * FROM login where password = '$opd'";
$sql = mysql_query($query,$con);
if(empty($sql))
{
echo"<script>alert('Enter correct username!');</script>";
}
else
{
$query1 = "SELECT * FROM login where password = '$opd'";
$query1 = "SELECT * FROM login where password = '$opd'";
$sql1 = mysql_query($query1,$con);
$row = mysql_fetch_array($sql1);
if($_POST['npwd'] == $_POST['rnpwd'])
{
$usr = $row['username'];
$pwd = $_POST['npwd'];
$query2 = "UPDATE login set password= '$pwd' WHERE username = '$usr'";
if(isset($query))
$sql2 = mysql_query($query2,$con);
header("Location:index.php");
}
else
{
echo"<script>alert('Enter correct matching password!');</script>";
}
}
}
?>
<br /><br /><input type ="submit" value="Submit">
</center>
</form>
</body>
</html>