-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
60 lines (52 loc) · 1.56 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
<?php
// include database connection file
include_once("koneksi.php");
// Check if form is submitted for user update, then redirect to homepage after update
if(isset($_POST['update']))
{
$id = $_POST['id'];
$lat=$_POST['lat'];
$long=$_POST['long'];
// update user data
$result = mysqli_query($connect, "UPDATE positive SET lat='$lat',long='$long' WHERE id=$id");
// Redirect to homepage to display updated user in list
header("Location: index.php");
}
?>
<?php
// Display selected user data based on id
// Getting id from url
$id = $_GET['id'];
// Fetech user data based on id
$result = mysqli_query($connect, "SELECT * FROM positive WHERE id=$id");
while($user_data = mysqli_fetch_array($result))
{
$lat = $user_data['lat'];
$long = $user_data['long'];
}
?>
<html>
<head>
<title>Edit User Data</title>
</head>
<body>
<a href="index.php">Home</a>
<br/><br/>
<form lat="update_user" method="post" action="edit.php">
<table border="0">
<tr>
<td>lat</td>
<td><input type="text" lat="lat" value=<?php echo $lat;?>></td>
</tr>
<tr>
<td>long</td>
<td><input type="text" lat="long" value=<?php echo $long;?>></td>
</tr>
<tr>
<td><input type="hidden" lat="id" value=<?php echo $_GET['id'];?>></td>
<td><input type="submit" lat="update" value="Update"></td>
</tr>
</table>
</form>
</body>
</html>