Question: I'm having a problem with my website. Im trying to add a product but its stuck to loading. createProduct.php Home Product Manage Product Add Product

I'm having a problem with my website. Im trying to add a product but its stuck to loading.

createProduct.php

require_once 'core.php';

$valid['success'] = array('success' => false, 'messages' => array());

if($_POST) {

$productName = $_POST['productName'];

$productImage = $_POST['productImage'];

$quantity = $_POST['quantity'];

$rate = $_POST['rate'];

$brandName = $_POST['brandName'];

$categoryName = $_POST['categoryName'];

$productStatus = $_POST['productStatus'];

$type = explode('.', $_FILES['productImage']['name']);

$type = $type[count($type)-1];

$url = '../assests/images/stock/'.uniqid(rand()).'.'.$type;

if(in_array($type, array('gif', 'jpg', 'jpeg', 'png', 'JPG', 'GIF', 'JPEG', 'PNG'))) {

if(is_uploaded_file($_FILES['productImage']['tmp_name'])) {

if(move_uploaded_file($_FILES['productImage']['tmp_name'], $url)) {

$sql = "INSERT INTO product (product_name, product_image, brand_id, categories_id, quantity, rate, active, status)

VALUES ('$productName', '$url', '$brandName', '$categoryName', '$quantity', '$rate', '$productStatus', 1)";

if($connect->query($sql) === TRUE) {

$valid['success'] = true;

$valid['messages'] = "Successfully Added";

} else {

$valid['success'] = false;

$valid['messages'] = "Error while adding the members";

}

} else {

return false;

} // /else

} // if

} // if in_array

$connect->close();

echo json_encode($valid);

} // /if $_POST

product.php

  1. Home
  2. Product

Manage Product

Photo Product Name Rate Quantity Brand Category Status Options

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!