我创建了一个输入数据的表单,然后将其保存到数据库中。我的数据库是使用PHPMyAdmin创建的,主键是自动递增的(所以这已被排除)。我可以输入数据但只能输入一次,之后不会出现任何添加的数据。任何帮助将不胜感激。
数据输入代码:
if(isset($_POST['insert_post'])){
//getting text from the form fields
$product_title = $_POST['product_title'];
$product_cat = $_POST['product_cat'];
$product_brand = $_POST['product_brand'];
$product_price = $_POST['product_price'];
$product_desc = $_POST['product_desc'];
$product_keywords = $_POST['product_keywords'];
//image from table field
$product_image = $_FILES['product_image']['name'];
$product_image_tmp = $_FILES['product_image']['tmp_name'];
move_uploaded_file($product_image_tmp,"product_images/$product_image");
$insert_product = "INSERT INTO 'products'
(product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) VALUES ('$product_cat','$product_brand',' $product_title','$product_price','$product_desc',' $product_image',' $product_keywords')";
$insert_pro = mysqli_query($con, $insert_product);
if($insert_pro){
echo "<script>alert('Product has been inserted')</script>";
echo "<script>window.open('insert_product.php','_self'</script>";
}