Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Last active August 31, 2018 20:44
Show Gist options
  • Save IhwanID/502e4b06e68ca045e6c8664f6b462ea8 to your computer and use it in GitHub Desktop.
Save IhwanID/502e4b06e68ca045e6c8664f6b462ea8 to your computer and use it in GitHub Desktop.
<?php
//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_post.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'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment