-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.php
155 lines (136 loc) · 4.92 KB
/
edit.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
include('config.php');
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" href="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Edit</title>
</head>
<body>
<div class="row">
<div class="col-md-10 col-xs-11" >
<p>Local Welfare Management</p>
</div>
<div class="col-md-2 col-xs-1">
<a type="button" class="button" href="index.html" >Back</a>
</div>
</div>
<div class="row">
<div class="col-md-3 col-xs-2 col-sm-2"></div>
<div class="col-md-6 col-xs-8 col-sm-8" id="form" style="padding-top: 10px;padding-bottom: 20px">
<form method="post" action="edit.php">
<center><p>Edit profile</p></center>
<?php
$sql="SELECT * FROM officers where password='".$_SESSION['password']."' AND phone='".$_SESSION['phone']."'" ;
$result=$con->query($sql);
if($result->num_rows>0)
{
while ($row=$result->fetch_assoc())
{$id= $row['id'];
?>
<table id="form">
<tr>
<th>Name</th>
<td><?php echo $row['name'];?><br>
<div id="demo1"></div></td>
<th><a type="button" onclick="myFunction1()" style="margin-left: 20px"> <i class="fa fa-edit">edit</i></a></th>
</tr>
<tr>
<th>Phone</th>
<td><?php echo $row['phone'];?><br>
<div id="demo2"></div></td>
<th><a type="button" onclick="myFunction2()" style="margin-left: 20px"> <i class="fa fa-edit">edit</i></a></th>
</tr>
<tr>
<th>E-mail</th>
<td><?php echo $row['email'];?><br>
<div id="demo3"></div></td>
<th><a type="button" onclick="myFunction3()" style="margin-left: 20px"> <i class="fa fa-edit">edit</i></a></th>
</tr>
<tr>
<th>Gender</th>
<td><?php echo $row['gender'];?><br>
<div id="demo4"></div></td>
<th><a type="button" onclick="myFunction4()" style="margin-left: 20px"> <i class="fa fa-edit">edit</i></a></th>
</tr>
<tr>
<th>Age</th>
<td><?php echo $row['age'];?><br>
<div id="demo5"></div></td>
<th><a type="button" onclick="myFunction5()" style="margin-left: 20px"> <i class="fa fa-edit">edit</i></a></th>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="submit" ></td>
<td></td>
</tr>
<?php } ?> </table> <?php } ?>
<?php
if(isset($_POST['submit'])){
if($_POST['name']!=''){
$name=$_POST['name'];
$sql="UPDATE officers SET name = '$name' where id='$id'";
$update = $mysqli->prepare($con,$sql);
}
if($_POST['phone']!=''){
$phone=$_POST['phone'];
$update_profile1 = $mysqli->query($con,"UPDATE officers SET phone = '$phone' where password='".$_SESSION['password']."' AND phone='".$_SESSION['phone']."'");
}
if($_POST['email']!=''){
$email=$_POST['email'];
$update_profile2 = $mysqli->query("UPDATE officers SET email = '$email' where password='".$_SESSION['password']."' AND phone='".$_SESSION['phone']."'");
}
if($_POST['age']!=''){
$age=$_POST['age'];
$update_profile3 = $mysqli->query("UPDATE officers SET age = '$age' where password='".$_SESSION['password']."' AND phone='".$_SESSION['phone']."'");
}
if ($update_profile || $update_profile1 || $update_profile2 || $update_profile3) {
header("Location: admin_page.php?user=$user");
} else {
echo $mysqli->error;
}
}
?>
</div>
</div>
<style type="text/css">
table,td,th{
border: 1px solid white;
margin-bottom: 20px;
}
td{
height: 50px;
width: 500vh;
}
</style>
<script>
function myFunction1()
{
document.getElementById("demo1").innerHTML = "<input type='text' name='name' >";
}
function myFunction2()
{
document.getElementById("demo2").innerHTML = "<input type='phone' name='phone' >";
}
function myFunction3()
{
document.getElementById("demo3").innerHTML = "<input type='text' name='email' >";
}
function myFunction4()
{
document.getElementById("demo4").innerHTML = "<input type='text' name='gender' >";
}
function myFunction5()
{
document.getElementById("demo5").innerHTML = "<input type='text' name='age' >";
}
</script>
</body>
</html>