Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "koneksi/koneksi.php";
- session_name('profil');
- session_start();
- if (isset($_SESSION['profil-username'])) {
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Input Penelitian | Sistem Informasi Perikanan Palabuhanratu</title>
- <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
- <!-- bootstrap 3.0.2 -->
- <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
- <!-- font Awesome -->
- <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
- <!-- Ionicons -->
- <link href="css/ionicons.min.css" rel="stylesheet" type="text/css" />
- <!-- Theme style -->
- <link href="css/AdminLTE.css" rel="stylesheet" type="text/css" />
- <!-- Favicon -->
- <link rel="shortcut icon" href="img/favicon.ico" />
- <!-- bootstrap wysihtml5 - text editor -->
- <link href="css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" />
- <style>
- .callout {
- margin-bottom: 0;
- }
- .row {
- margin-bottom: 15px;
- }
- .wysiwyg {
- width: 100%;
- height: 200px;
- font-size: 14px;
- line-height: 18px;
- border: 1px solid #dddddd;
- padding: 10px;
- }
- .wysiwyg:focus{
- border-color: #3c8dbc !important;
- box-shadow: none;
- outline: 0;
- }
- #txt-file {
- padding: 5px 5px;
- }
- </style>
- </head>
- <body class="skin-blue">
- <?php include 'includes/header.php'; ?>
- <div class="wrapper row-offcanvas row-offcanvas-left">
- <!-- Left side column. contains the logo and sidebar -->
- <?php include 'includes/menu.php'; ?>
- <!-- Right side column. Contains the navbar and content of the page -->
- <aside class="right-side">
- <!-- Content Header (Page header) -->
- <section class="content-header">
- <h1>
- Berita
- <small><i class="fa fa-angle-right"></i> Input Berita</small>
- </h1>
- </section>
- <!-- Main content -->
- <section class="content">
- <!-- top row -->
- <div class="row">
- <div class="col-md-10">
- <!-- general form elements -->
- <div class="box box-info">
- <div class="box-header">
- <h3 class="box-title"><i class="fa fa-edit"></i> FORM INPUT BERITA</h3>
- </div><!-- /.box-header -->
- <?php
- // -------------------- SIMPAN BERITA --------------------
- if (isset($_POST['simpan-berita'])) {
- $id_pengguna = $_SESSION['profil-id'];
- $judul = $_POST['judul'];
- $isi = $_POST['isi'];
- $label = $_POST['label'];
- $cek_judul = mysqli_query($db, "SELECT id FROM berita WHERE judul='$judul'");
- if (mysqli_num_rows($cek_judul) > 0) {
- echo "<script>alert('Judul sudah ada !')</script>";
- } else {
- if ($_FILES['gambar']['tmp_name'] != '') {
- $gambar = $_FILES['gambar']['tmp_name'];
- $gambar_name = $_FILES['gambar']['name'];
- $gambar_size = $_FILES['gambar']['size'];
- if ($gambar_size > 1000000) {
- echo "<script>alert('Ukuran gambar terlalu besar !')</script>";
- } else {
- move_uploaded_file($gambar, 'gambar/'.$gambar_name); // simpan gambar
- $simpan_berita = mysqli_query($db, "INSERT INTO berita(id_pengguna, judul, isi, tgl, label, gambar, status) VALUES('$id_pengguna', '$judul', '$isi', NOW(), '$label', '$gambar_name', 'publish')");
- }
- } else {
- $simpan_berita = mysqli_query($db, "INSERT INTO berita(id_pengguna, judul, isi, tgl, label, gambar, status) VALUES('$id_pengguna', '$judul', '$isi', NOW(), '$label', '', 'publish')");
- }
- if ($simpan_berita == true) {
- echo "<script>alert('Berita telah disimpan')</script>";
- } else {
- echo "<script>alert('Gagal menyimpan data. ".mysqli_error($db)."')</script>";
- }
- }
- }
- ?>
- <!-- form start -->
- <form role="form" enctype="multipart/form-data" method="POST">
- <div class="box-body">
- <div class="form-group">
- <label for="txt-judul">Judul Berita</label>
- <input type="text" class="form-control" name="judul" required autofocus />
- </div>
- <div class="form-group">
- <textarea class="wysiwyg" name="isi" placeholder="Isikan konten berita di sini ..." required></textarea>
- </div>
- <div class="row">
- <div class="col-xs-5">
- <label>Gambar</label>
- <input type="file" accept=".jpg" name="gambar" class="form-control" />
- <span class="help-block">Gunakan gambar dengan ekstensi *.JPG</span>
- </div>
- <div class="col-xs-7">
- <label>Label</label>
- <input type="text" name="label" class="form-control" required />
- </div>
- </div>
- </div><!-- /.box-body -->
- <div class="box-footer">
- <button type="submit" name="simpan-berita" class="btn btn-info"><i class="fa fa-check"></i> Simpan</button>
- <button type="reset" class="btn btn-default"><i class="fa fa-repeat"></i> Ulangi</button>
- </div>
- </form>
- </div><!-- /.box -->
- </div><!-- /.col -->
- </div>
- <!-- /.row -->
- </section><!-- /.content -->
- </aside><!-- /.right-side -->
- </div><!-- ./wrapper -->
- <!-- add new calendar event modal -->
- <!-- jQuery 2.0.2 -->
- <script src="js/jquery.min.js"></script>
- <!-- jQuery UI 1.10.3 -->
- <script src="js/jquery-ui-1.10.3.min.js" type="text/javascript"></script>
- <!-- Bootstrap -->
- <script src="js/bootstrap.min.js" type="text/javascript"></script>
- <!-- AdminLTE App -->
- <script src="js/AdminLTE/app.js" type="text/javascript"></script>
- <!-- InputMask -->
- <script src="js/plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
- <script src="js/plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
- <script src="js/plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
- <!-- Bootstrap WYSIHTML5 -->
- <script src="js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
- <!-- Inline Scripts -->
- <script type="text/javascript">
- /* wysiwyg */
- $(".wysiwyg").wysihtml5({
- "font-styles": true,
- "emphasis": true,
- "lists": true,
- "html": false,
- "link": false,
- "image": false,
- "color": true
- });
- </script>
- </body>
- </html>
- <?php
- } else {
- header('location:login.php');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement