[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
campus
/
admin
/
[
Home
]
File: tambah_berita.php
<?php session_start(); if (!isset($_SESSION['admin_logged_in'])) { header("Location: login.php"); exit; } include '../config/koneksi.php'; if (isset($_POST['simpan'])) { $judul = mysqli_real_escape_string($conn, $_POST['judul']); $isi = mysqli_real_escape_string($conn, $_POST['isi']); $tanggal = date('Y-m-d'); // Upload Gambar $gambar = $_FILES['gambar']['name']; $tmp = $_FILES['gambar']['tmp_name']; $path = "../uploads/" . $gambar; if (!empty($gambar)) { move_uploaded_file($tmp, $path); $query = "INSERT INTO berita (judul, isi, gambar, tanggal) VALUES ('$judul', '$isi', '$gambar', '$tanggal')"; } else { $query = "INSERT INTO berita (judul, isi, tanggal) VALUES ('$judul', '$isi', '$tanggal')"; } mysqli_query($conn, $query); header("Location: berita.php"); } ?> <!DOCTYPE html> <html lang="id"> <head> <title>Tambah Berita</title> <style> body { font-family: sans-serif; padding: 20px; max-width: 800px; margin: auto; } .form-group { margin-bottom: 15px; } label { display: block; font-weight: bold; margin-bottom: 5px; } input[type="text"], textarea { width: 100%; padding: 10px; border: 1px solid #ccc; box-sizing: border-box; } .btn { background: #003366; color: white; padding: 10px 20px; border: none; cursor: pointer; } </style> </head> <body> <h2>Tambah Berita Baru</h2> <a href="berita.php" style="text-decoration: none;">← Kembali</a> <br><br> <form action="" method="post" enctype="multipart/form-data"> <div class="form-group"> <label>Judul Berita</label> <input type="text" name="judul" required> </div> <div class="form-group"> <label>Gambar</label> <input type="file" name="gambar"> </div> <div class="form-group"> <label>Isi Berita</label> <textarea name="isi" rows="10" required></textarea> </div> <button type="submit" name="simpan" class="btn">Simpan</button> </form> </body> </html>