-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_feature.php
More file actions
84 lines (83 loc) · 2.53 KB
/
Copy pathedit_feature.php
File metadata and controls
84 lines (83 loc) · 2.53 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
84
<?php include 'includes/config.php';
if (isset($_GET['updatef'])) {
$name = sanitizeData($_GET['fname']);
$desc = sanitizeData($_GET['fdes']);
$id = sanitizeData($_GET['id']);
$update_sql="UPDATE features
SET feature_name='".$name."',feature_des='".$desc."' where id='".$id."'";
mysqli_query($db,$update_sql);
?>
<style>
.admin-form{
display:none;
}
header{
display:none;
}
</style>
<?php
echo 'Successfully updated the feature!';
header( "refresh:2;url=dashboard.php" );
}
else if (isset($_GET['deletef'])) {
$id = sanitizeData($_GET['id']);
$delete_sql="delete from features where id='".$id."'";
$db->query($delete_sql);
?>
<style>
.admin-form{
display:none;
}
header{
display:none;
}
</style>
<?php
echo 'Successfully deleted the feature!';
header( "refresh:2;url=dashboard.php" );
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hostel Tracker</title>
<meta charset="utf-8">
<?php include 'includes/links.php'; ?>
</head>
<body>
<?php
include "includes/header.php";
?>
<div class="admin-form">
<?php
if (isset($_SESSION['email'])) {
$sql="select * from features where id='".$_GET['id']."';";
$result = mysqli_query($db,$sql);
$product_array = mysqli_fetch_assoc($result);
?>
<h1>Add Feature!</h1>
<form action="#" method="get">
<div>
<input type="hidden" name="id" value="<?php echo $product_array['id'] ?>" required>
</div>
<div>
<input type="text" name="fname" value="<?php echo $product_array['feature_name'] ?>" required>
</div>
<div>
<textarea name="fdes" required><?php echo $product_array['feature_des'] ?></textarea>
</div>
<div>
<button type="submit" name="updatef">Update Feature</button>
<button type="submit" name="deletef">Delete Feature</button>
</div>
</form>
<?php
}
else
{
?><p>Not Logged In!</p><?php
}
?>
</div>
</body>
</html>