-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassupdate.php
More file actions
83 lines (72 loc) · 2.08 KB
/
Copy pathpassupdate.php
File metadata and controls
83 lines (72 loc) · 2.08 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
83
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
?>
<html>
<head>
<meta charset="UTF-8">
<title>Login Form</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header>
<nav>
<div class="main_wrapper">
<footer>
<a href="index1.php"> HOME</a></footer>
<center><h2> PASSWORD UPDATE</h2></center>
</div>
</nav>
</header>
<div class="main_login">
<center>
<form class="login-form" action="" method= "post">
USERNAME:
<input type="text" name="username" placeholder="username">
<br>
<br>
<br>
PASSWORD:
<input type="password" name="password" placeholder="password">
<br>
<br>
<br>
<button type="submit" name="submit">UPDATE</button>
</form>
</center>
</div>
</body>
</html>
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
session_start();
include 'db_con.php';
$user="";
if(isset($_POST['submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
$query1="select username from registration";
$res= queryMysql($query1);
while($row= mysqli_fetch_array($res,MYSQLI_ASSOC)){
$user=$row['username'];
}
if(empty($_POST['username'])){
echo '<script>alert("check username")</script>';
}
$query="update registration set password='$password' where username='$username'";
$res= queryMysql($query);
if ($username==$user) {
echo '<script>alert("password updated")</script>';
}
else{
echo '<script>alert("password update failed")</script>';
}
}
?>