 |
|
Code (PHP)
<?php
include("conectdatabase.php");
if($_POST["addproduct"] == "add"){
$sql = "select * from promotion where pic1 = '".$_FILES["txtfile"]["name"]."' or pic2 = '".$_FILES["txtfile"]["name"]."' or pic3 = '".$_FILES["txtfile"]["name"]."' or pic4 = '".$_FILES["txtfile"]["name"]."' or pic5 = '".$_FILES["txtfile"]["name"]."' or pic6 = '".$_FILES["txtfile"]["name"]."' or pic7 = '".$_FILES["txtfile"]["name"]."' or pic8 = '".$_FILES["txtfile"]["name"]."' or image = '".$_FILES["txtfile"]["name"]."' ";
$result1 = mysqli_query($conn,$sql);
$num = mysqli_num_rows($result1);
if($num > 0)
{
echo "<script>";
echo "alert('ชื่อรูปซ้ำ!');";
echo "window.location='page.php'";
echo "</script>";
}else {
$sql = "SELECT * FROM promotion WHERE id_register = '".$_POST["UserID"]."' ";
$objQuery = mysqli_query($conn,$sql);
$Num_Rows = mysqli_num_rows($objQuery);
if($Num_Rows == 100){
echo "<script>";
echo "alert('จำกัด 50 รายการ');";
echo "window.location='page.php'";
echo "</script>";
} else {
move_uploaded_file($_FILES["txtfile"]["tmp_name"],"imgpromotion/".$_FILES["txtfile"]["name"]);
$sql = "INSERT INTO promotion (id_register,nameshop,nameproduct,price,price2,image,discription,descriptionunder) VALUES ('".$_POST["UserID"]."','".$_POST["txtnameshop"]."','".$_POST["txtnamepro"]."','".$_POST["txtprice"]."','".$_POST["txtprice2"]."','".$_FILES['txtfile']['name']."','".$_POST["textareaproduct"]."','".$_POST["textareaproductUnder"]."')";
$objQuery = mysqli_query($conn,$sql);
echo "<script>";
echo "window.location='page.php?page=home' ";
echo "</script>";
}
}
}
?>
Tag : PHP
|
ประวัติการแก้ไข 2019-09-26 19:13:34
|
 |
 |
 |
 |
Date :
2019-09-26 13:56:35 |
By :
BABANGYAI |
View :
631 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |