-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
51 lines (37 loc) · 1.27 KB
/
update.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
<?php
//set session
session_start();
if(! isset($_SESSION['loggedin']))
exit('akses dilarang, silahkan login dulu');
include_once('config.php');
$judul = "Edit Post";
$subjudul = "";
$url_banner = "assets/img/home-bg.jpg";
$id = $_GET['id'];
$query = mysqli_query($mysqli, 'SELECT * FROM posts WHERE id =' . $id);
$post = mysqli_fetch_assoc($query);
if(isset($_POST['submit'])){
$judul = $_POST['judul'];
$konten = $_POST['konten'];
mysqli_query($mysqli, 'UPDATE posts SET judul = "'.$judul.'" , konten = "'.$konten.'" WHERE id ='. $id);
if($query){
header('Location: index.php');
}else{
$error = "Error : " . mysqly_error($mysqli);
}
}
?>
<?php include('header.php'); ?>
<!-- Main Content -->
<div class="container">
<form action="update.php?id=<?php echo $id; ?>" method="post">
<label >Judul Artikel</label>
<input type="text" name="judul" class="form-control" value="<?php echo $post['judul'] ?>">
<br>
<label>Isi Artikel</label>
<textarea name="konten" class="form-control"><?php echo $post['konten'] ?></textarea>
<hr>
<button type="submit" name="submit" value="submit">Submit Artikel</button>
</form>
</div>
<?php include('footer.php'); ?>