|
 |
|
PHP MSQL เว็บบอร์ด เพิ่มกระทู้ลงดาต้าเบสได้ แต่ไม่เก็บค่าหมวดหมู่ ทำไงดีคะ |
|
 |
|
|
 |
 |
|
จะดึงค่าของหมวดหมู่ยังไงคะ เช่น
เข้าหมวดหมู่ พูดคุยทั่วไป ID หมวดหมู่ คือ 1 จะมีฟอร์มให้ตั้งกระทู้ ในแต่ละหมวดหมู่
และก็ยังเช็คไฟล์ที่ส่งมาไม่ได้ด้วยค่ะ จะให้อัพโหลดเฉพาะไฟล์ mp3 เท่านั้น ทำไงดีคะ
Code (PHP)
<?
include("connect.php");
$forum_id =$_GET['forumid'];
$subject =$_POST['subject'];
$post_detail =$_POST['post_detail'];
$attach_file =$_FILES['attach_file'];
$song_name =$_POST['song_name'];
$singer_name =$_POST['singer_name'];
$date_post =date("Y-m-d H:i:s");
if (empty($subject) || empty($post_detail) || empty($song_name) || empty($singer_name))
{
echo "<script> alert ('กรุณากรอกข้อมูลให้ครบถ้วน') ; history.back();</script>";
exit();
}
if ($attach_file != "") // ตรวจสอบว่ามีไฟล์ส่งมาหรือไม่
{
if(strchr($attach_file_name,".")==".MP3" || strchr($attach_file_name,".")==".mp3")
{
copy($attach_file,"song/".$attach_file_name); // Copy File ไว้ที่ Folder song
}else{
echo "<script> alert ('ไฟล์ที่แนบมา ไม่ใช่ไฟล์ mp3 นะคะ') ; history.back();</script>";
exit ();
}
}
$sql="INSERT INTO `webboard_post`(`question_id` ,`forum_id`,`subject` ,`post_detail` ,`user_id`,`attach_file` ,`count_view` ,`song_name`,`singer_name`,`date_post` )VALUES
('' ,'$forum_id','$subject', '$post_detail','".$_SESSION['user_id']."','$attach_file','0', '$song_name', '$singer_name','date_post');";
$mysql = mysql_db_query($db,$sql);
{
echo "<script> alert ('เพิ่มกระทู้เรียบร้อยแล้ว') ; history.back();</script>";
}
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2011-07-02 17:40:40 |
By :
nokz |
View :
846 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้เรียบร้อยแล้วค่ะพี่วิน ขอบคุณมากค่ะ
แต่ว่ายังติดตรงอัพโหลดไฟล์ค่ะ จะเช็คยังไงดีคะ
|
 |
 |
 |
 |
Date :
2011-07-02 18:12:07 |
By :
nokz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|