HTTP 500 PHP/MYSQL Help required

If someone can help me to solve this issue? when I submit form its come with HTTP500 Error, no record insert into SQL database,

if someone can help ?

Here is a database structure

Coding
include(’…/connection.php’);

if (isset($_GET['action']) && $_GET['action'] == 'add-product' && isset($_POST['add-product-btn'])) {
	
	if (($_FILES['image']['name']!="")){

		$target_dir = "upload/";
		$file = $_FILES['image']['name'];
		$path = pathinfo($file);
		$filename = getRandomValue().'-'.$path['filename'];
		$ext = $path['extension'];
		$temp_name = $_FILES['image']['tmp_name'];
		$path_filename_ext = $target_dir.$filename.".".$ext;
		
		move_uploaded_file($temp_name,$path_filename_ext);
		
		$data = [];

		array_push($data, $_POST['product-name']);
		array_push($data, $_POST['video-link']);
		array_push($data, $filename.'.'.$ext);
		array_push($data, $_POST['product-description']);
		array_push($data, json_encode($_POST['product-category']));
		array_push($data, $_POST['short-description']);
		array_push($data, json_encode($_POST['product_process']));

$query = mysqli_query($con, “INSERT INTO products( product_name, product_video_link, product_image, product_description, product_category, short_description, product_process) VALUES (’$data[0]’, ‘$data[1]’, ‘$data[2]’, ‘$data[3]’, ‘$data[4]’, ‘$data[5]’, ‘$data[6]’)”);

		if ($query > 0) {
			
			$_SESSION['product_success'] = "Product addedd Successfully!";

			header('location: products.php');			

		}else{
			
			$_SESSION['product_error'] = "Product couldn't be added. Please try later...";

			header('location: add-product.php');

Check your web server error log to see a more (or less) descriptive error, starting with that allows you to not fumble blind trying to solve issues

Or if you cant find the error log turn on php errors and try to post the form again. The php code after forms often perform a redirect after submission. To see the error messages you could place an exit; statement just before the redirect (which are fired by an header(‘Location: …’); function).

Sponsor our Newsletter | Privacy Policy | Terms of Service