Last active
August 31, 2018 20:45
-
-
Save IhwanID/0a6e8d184ed12c0d0f4fd188319953cb to your computer and use it in GitHub Desktop.
sample code of create post in workshop blog php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//session_start(); | |
//if(! isset($_SESSION['loggedin'])) | |
//exit('akses dilarang, silahkan login dulu'); | |
include_once('config.php'); | |
$judul = "Tambah Post"; | |
$subjudul = ""; | |
$url_banner = "assets/img/home-bg.jpg"; | |
if(isset($_POST['submit'])){ | |
$judul = $_POST['judul']; | |
$konten = $_POST['konten']; | |
$query = mysqli_query($mysqli, 'INSERT INTO posts (judul, konten) VALUES ("'.$judul.'" , "'.$konten.'")'); | |
if($query){ | |
header('Location: index.php'); | |
}else{ | |
$error = "Error : " . mysqli_error($mysqli); | |
} | |
} | |
?> | |
<?php include('header.php'); ?> | |
<!-- Main Content --> | |
<div class="container"> | |
<form action="create_post.php" method="post"> | |
<label >Judul Artikel</label> | |
<input type="text" name="judul" class="form-control"> | |
<br> | |
<label>Isi Artikel</label> | |
<textarea name="konten" class="form-control"></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