สอบถามการ เก็บข้อมูล ลงในฐานข้อมูล

กระทู้คำถาม
ภาพนี้เป็นส่วนของดาต้าเบสเราค่ะ
https://www.img.in.th/image/DdCIPu

ปัญหาคือ เรากดบันทึกไม่ได้ค่ะ
https://www.img.in.th/image/DdCaXJ

********* code หน้า ฟอร์มนะคะ
<?php
include 'connectdb.php';
?>
<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8">
<h1 style="text-align:center;">เพิ่มสถานที่ท่องเที่ยว</h1>

<style>
label {
display: block;
}
</style>

<script src="../ckeditor/ckeditor.js"></script>
<body bgcolor="#F0FFF0">
</head>
<body>

<from id="from1" action="insert_news.php" method="post" encttype="multipant/from-data">
<label for="newstype">เลือกประเภทสถานที่ท่องเที่ยว</label>
<select name ="newtype">
<option value="">--กรุณาเลือกประเภทสถานที่ท่องเที่ยว--</option>
<?php
$sql_newstype="SELECT * FROM tbnewtype";
$res_newtype= mysqli_query($dbcon, $sql_newstype);
while ($row_newstype= mysqli_fetch_assoc($res_newtype)){
echo '<option value="'.$row_newstype['newstype_id'].'">'.$row_newstype['newstype_detail'].'</option>';
}
?>
</select>
<label for="news_topic">เพิ่มหัวข้อข่าว</label>
<input type="text" name="news_topic" required>
<label for="news_detail">เนื้อหาข่าว</label>
<textarea name="news _detail" id=news_detail" rows="20" cols="130">

</textarea>
<script>

CKEDITOR.replace( 'news _detail' ,{
uiColor: '#E6E6FA'

});

</script>

<label for="news_filename">ภาพประกอบข่าว</label>
<input type="file" name="news_filename">
<label for="news_status">สถานะข่าว</label>
<input type="radio" value="0" checked name="news_status"> สถานทีท่องเที่ยวทั่วไป <br>
<input type="radio" value="1" name="news_status">  สถานที่ท่องเที่ยวที่เด่น
<br>
<input type="submit" value="บันทึก">

</from>

<a href="../index.php">
<br>
<br>
กลับสู่หน้าหลัก</a>

</body>
</html>

************code หน้าฐานข้อมูล

<?php

include 'connectdb.php';

$newstype_id = $_POST['newstype'];
$news_topic = $_POST['news_topic'];
$news_detail = $_POST['news_detail'];
$news_status = $_POST['news_status'];

//up
$image_ext = pathinfo(basename($_FILES['news_filename']['name']), PATHINFO_EXTENSION);
$new_image_name = 'news_'.uniqid().".".$image_ext;
$image_path = "../news_image/";
$image_upload_path = $image_path.$new_image_name;
$success = move_uploaded_file($_FILES['news_filename']['tmp_name'],$image_upload_path);
if ($success==false) {
echo "ไม่สามารถ upload รูปภาพได้";
exit();
}

//insere data
$sql = "INSERT INTO tbnew (news_topic,news_detail,news_filename,news_status,news_data,newstype_id) ";
$sql .= " VALUES ('$news_topic','$news_detail','$new_image_name','$news_status',NOW(),'$newstype_id')";
$resulf = mysqli_query($dbcon, $sql);

if ($result) {
echo "บันทึกข้อมูลเรียบร้อยแล้ว";
header("Location: main.php");
} else {
echo "เกิดข้อผิดพลาด ". mysqli_error($dbcon);
}

?>
คำตอบที่ได้รับเลือกจากเจ้าของกระทู้
ความคิดเห็นที่ 2
อาจารย์ค่ะ รบกวนอีกนิดได้ไหมค่ะ ตอนนี้เข้าเงื่อนไขแล้ว แต่หนูไม่รู้ว่าหนูเชื่อมดาต้าเบสตรงไหนผิด ตอนนี้มันเข้าเงื่อนไข
if ($success==false) {
echo "ไม่สามารถ upload รูปภาพได้";
exit();
https://www.img.in.th/image/DjIj3j
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่