  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                สวัสดีครับ ผมจะทำระบบข้อมูลที่มีรูปอยู่ด้วยแต่ งง ตรงที่ว่า มัน บันทึกชื่อลิ้งรูปลงฐานข้อมูลไม่ได้อะครับ  
รบกวนผู้รู้ช่วยทีนะครับ  
 
form 
 
Code (PHP) 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?
	#include "date.php";
?>
<form id="form1" name="form1" method="post" action="addnewsscript.php">
  <label>
  <p align="center">ระบบเพิ่มข่าวสาร</p>
  หัวข้อข่าวสาร 
  <input name="title" type="text" size="100" />
  </label>
  <p align="left">เนื้อหาข่าวสาร  </p>
  <p>
    <label>
    <textarea name="detail" cols="150" rows="15"></textarea>
    </label>
  </p>
    <label>
    <INPUT type="file" name="photo">
    *.gif,*.jpg,*.jpeg เท่านั้น<br />
	</label>  
   <p>
    <label>
    <input type="submit" name="add" id="add" value="เพิ่มข่าวสาร" />
    </label>
    <label>
    <input type="reset" name="reset" id="reset" value="ล้างข้อมูล" />
    </label>
  </p>
  <p>กลับสู่หน้าผู้ดูแล</p>
</form>
</body>
</html>
 
 
 
Codeนะครับ 
Code (PHP) 
<?
	$title=$_POST[title];
	$detail=$_POST[detail];
	$photo=$_FILES['photo']['tmp_name'];
	$photo_name=$_FILES['photo']['name'];
	$photo_size=$_FILES['photo']['size'];
	$photo_type=$_FILES['photo']['type'];
	$date_today=date("Y-m-d");
	$time_today=date("H:i:s");
	include "connect.php";
	$sql="select * from news where date_news='$date_today'";
	$array_last=explode(".",$photo_name);
	$c=count($array_last)-1;
	$lastname=strtolower($array_last[$c]);
	if($lastname=="gif"or $lastname=="jpg" or $lastname=="jpeg"){
		copy($photo,"images/".$photo_name);
	}
	$result=mysql_db_query("$dbname",$sql);
	$number=mysql_num_rows($result);
	if ($number!=0){
		echo "ไม่อนุญาตให้เพิ่มข่าวสารได้";
	}else{
		$sql_insert="INSERT INTO news VALUES('','$title','$detail','$date_today','$time_today','$photo_name')";
		$result_insert=mysql_db_query("$dbname",$sql_insert);
		if($result_insert){
			echo "จัดเก็บข้อมูลเรียบร้อย";
			echo "<a href=main.php>กลับหน้าหลัก</a>";
		}else{
			echo"ไม่สามารถเพิ่มข้อมูลได้";
		}
	}
	unlink($photo);
	mysql_close();
?>
 
 
  Tag : PHP, MySQL, Web (ASP.NET)               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2010-12-13 10:24:54 | 
                      By :
                          middlesome | 
                      View :
                          986 | 
                      Reply :
                          4 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |