File manager - Edit - /home/webapp68.cm.in.th/u68319090013/projectfinal/wat-prasat/admin/news.php
Back
<?php session_start(); require '../backend/config.php'; if ($_SESSION['role'] !== 'admin') die('no access'); if (isset($_POST['save'])) { $title = $_POST['title']; $content = $_POST['content']; $img = ''; if ($_FILES['image']['name']) { $img = time().'_'.$_FILES['image']['name']; move_uploaded_file($_FILES['image']['tmp_name'], "../uploads/news/$img"); } $stmt = $conn->prepare("INSERT INTO news (title, content, image) VALUES (?,?,?)"); $stmt->bind_param("sss", $title, $content, $img); $stmt->execute(); } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="../css/style.css"> </head> <body> <div class="container"> <h2>เพิ่มข่าวสาร</h2> <form method="post" enctype="multipart/form-data"> <input type="text" name="title" placeholder="หัวข้อข่าว" required> <textarea name="content" placeholder="รายละเอียดข่าว" required></textarea> <input type="file" name="image"> <button name="save">บันทึกข่าว</button> </form> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.4 |
proxy
|
phpinfo
|
Settings