-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangepassword.php
112 lines (102 loc) · 2.92 KB
/
changepassword.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>change password</title>
<style>
body{
text-align:center;
}
table{
margin:100px auto;
}
#header{
width:100%;
height:50px;
background-color:skyblue;
text-align:center;
line-height:50px;
}
</style>
</head>
<body>
<h2 id="header"> Change Password</h2>
<table border="3" cellspacing="7">
<form action="" method="post">
<tr>
<td>username</td>
<td><input type="text" name="username1" id=""></td>
</tr>
<td>phone</td>
<td><input type="text" name="phone" id=""></td>
</tr>
<tr>
<td>new password</td>
<td><input type="password" name="password" id=""></td>
</tr>
<td>confirm new password</td>
<td><input type="password" name="conpassword" id=""></td>
</tr>
<tr><td><input type="submit" value="submit" name="submit"></td>
<td><input type="reset" value="reset" name="reset"></td>
</tr>
</form>
</table>
</body>
</html>
<?php
include("connection.php");
error_reporting(0);
if(isset($_POST["submit"]))
{
if(isset($_POST["username1"])&isset($_POST["password"])&isset($_POST["conpassword"])&isset($_POST["phone"]))
{
if(!empty($_POST["username1"])&!empty($_POST["password"])&!empty($_POST["conpassword"])&!empty($_POST["phone"]))
{
$username1=$_POST["username1"];
$pass=$_POST["password"];
$conpass=$_POST["conpassword"];
$phone=$_POST["phone"];
if($pass==$conpass)
{
$sql="select * from student where username ='$username1' && phone='$phone'";
$query=mysqli_query($conn,$sql);
$total=mysqli_num_rows($query);
if($total==1)
{
$sql1="update `student` set password='$pass',conpassword='$conpass' where username='$username1'";
$query1=mysqli_query($conn,$sql1);
if($query1)
{
echo "your password successfully updated";
?>
<meta http-equiv="Refresh" content="2; URL=index.php">
<?php
}
else{
die("your password not updated");
}
}
else
{
die("username and phone number are invalid");
}
}
else
{
die("password and confirm password are incorrect");
}
}
else
{
die("some fields are empty");
}
}
else
{
die("something went wrong");
}
}
?>