为什么PHP数据不会传输到PHP myadmin

时间:2017-06-27 02:58:44

标签: php html sql phpmyadmin

我正在尝试创建一个电子商务网站,管理员用户可以在其中添加项目。每次添加项目时,都应该通过PHP myAdmin将其带入SQL服务器。当我完成此代码时,它第一次传输数据,但此后已停止。我该如何解决这个问题?在此先感谢您的帮助。非常感谢。下面是我的PHP代码

<?php

if (isset($_POST['insert_post'])) {

    //getting the text data from the 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'];


    //getting the image from the 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>";

    }

}


?>

0 个答案:

没有答案