|
 |
|
รบกวนดูโค้ดให้หน่อยค่ะ ต้องการเช็คค่าให้กรอกอันใดอันนึง ห้ามเป็นค่าว่าง 2 อันคะ |
|
 |
|
|
 |
 |
|
รบกวนดูโค้ดให้หน่อยค่ะ คือว่าต้องการเช็คค่าให้กรอกอันใดอันนึงนะคะ ห้ามเป็นค่าว่างทั้ง 2 อันนะคะ ถ้าเป็นค่าว่างทั้ง 2 อัน ก็ไม่ให้แอดลงฐานข้อมูลนะคะ รบกวนดูโค้ดให้หน่อยค่ะ
test_upload.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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="browse.php" enctype="multipart/form-data">
File :
<input name="fileUpload" type="file" id="fileUpload" />
<label>
<input type="submit" name="Submit" value="Submit" />
</label> Msisdn :
<label>
<textarea name="msisdn" id="msisdn"></textarea>
</label>
</form>
</body>
</html>
browse.php
<html>
<head>
<title>ตัวอย่าง</title>
</head>
<body>
<?
$msisdn =$_POST['msisdn'];
$objCSV =$_FILES["fileUpload"];
$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database"); // Conect to MySQL
$objDB = mysql_select_db("test");
if ($msisdn!=''){
$sql = "INSERT INTO phone (`phone`) VALUES ('$msisdn');";
$re= mysql_query($sql);
}else if ($objCSV !=''){
copy($_FILES["fileUpload"]["tmp_name"],$_FILES["fileUpload"]["name"]);
$objCSV = fopen($_FILES["fileUpload"]["tmp_name"], "r");
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
$strSQL = "INSERT INTO phone ";
$strSQL .="(phone) ";
$strSQL .="VALUES ";
$strSQL .="('".$objArr[0]."') ";
$objQuery = mysql_query($strSQL);
}
fclose($objCSV);
}
echo "Import Done.";
?>
</table>
</body>
</html>
Tag : PHP, MySQL, JavaScript, CakePHP

|
|
 |
 |
 |
 |
Date :
2010-08-25 15:17:02 |
By :
ฟ้า |
View :
1114 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปลี่ยนแค่นี้ ครับ $objCSV =$_FILES["fileUpload"]["name"];
|
 |
 |
 |
 |
Date :
2010-08-25 15:21:21 |
By :
kaos |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|