-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_notice.php
83 lines (65 loc) · 1.99 KB
/
update_notice.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
<?php
require_once 'header.php';
require_once 'db_con.php';
session_start();
?>
<div class="container-fluid">
<div class="row" id="wrapper">
<?php require_once'menubar.php';?>
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-body">
<center><h3>Update Notice</h3></center>
<hr>
<?php
if(isset($_POST['submit'])){
$id = $_REQUEST['id'];
$title = $_POST['title'];
$message = $_POST['message'];
$date = date_create();
$time = date_format($date, 'Y-m-d H:i:s');
$sql = "UPDATE `notice` SET `title`='$title',`message`='$message',`time`='$time' WHERE id='$id'";
$result = mysqli_query($conn,$sql);
if($result){
header('Location:admin_notice.php');
}else{
echo "<div class='alert alert-danger'>";
echo "<strong>Error!</strong> in submission. Please try again";
echo "</div>";
}
}
?>
<div class="col-sm-10 col-sm-offset-2">
<?php
$id = $_REQUEST['id'];
$sql1 = "SELECT * FROM notice WHERE id='$id'";
$result1 = mysqli_query($conn,$sql1);
while($row = mysqli_fetch_array($result1)){
?>
<form action="update_notice.php" method="post" class="form-horizontal" role="form">
<div class="form-group">
<label for="title" class="col-sm-2 control-label">Notice Title:</label>
<div class="col-sm-7">
<input type="text" class="form-control" name="title" value="<?= $row['title']; ?>" >
</div>
</div>
<div class="form-group">
<label for="message" class="col-sm-2 control-label">Detail Notice:</label>
<div class="col-sm-7">
<textarea class="form-control" rows="15" name="message" ></textarea>
</div>
</div>
<center><input type="submit" name="submit" value="Update" class="btn btn-primary"></center>
<input type="hidden" name="id" value="<?=$id;?>" />
</form>
<br>
<br>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>