Php script not showing errors but only redirects to homepage

I am making e-commerce site and add to basket script not doing anything I expect it to insert data into shopping basket from products page that is working perfectly fine. Please have a look and help me figure it out.. it is not giving any syntax error or parse error it just dont do anything and when I click buy it just redirect me to homepage

<?php error_reporting(E_ALL); session_start(); require("db.php"); require("functions.php"); $  validid = pf_validate_number($  _GET['id'], "redirect", $  config_basedir); $  prodsql = "SELECT * FROM products WHERE id = " . $  _GET['id'] . ";"; $  prodres = mysqli_query($  prodsql); $  numrows = mysqli_num_rows($  prodres); $  prodrow = mysqli_fetch_assoc($  prodres); if($  numrows == 0) {        header("Location: " . $  config_basedir); } else {   if($  _POST['submit'])   {     if($  _SESSION['SESS_ORDERNUM'])     {       $  itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES("                  . $  _SESSION['SESS_ORDERNUM'] . ", "                  . $  _GET['id'] . ", "                  . $  _POST['amountBox'] . ")";       mysqli_query($  itemsql);     } else {       if($  _SESSION['SESS_LOGGEDIN'])       {         $  sql = "INSERT INTO orders(customer_id, registered, date) VALUES("                . $  _SESSION['SESS_USERID'] . ", 1, NOW())";         mysqli_query($  sql);         session_register("SESS_ORDERNUM");         $  _SESSION['SESS_ORDERNUM'] = mysqli_insert_id();         $  itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES("                    . $  _SESSION['SESS_ORDERNUM']                    . ", " . $  _GET['id'] . ", "                    . $  _POST['amountBox'] . ")";         mysqli_query($  itemsql);       } else {         $  sql = "INSERT INTO orders(registered, date, session) VALUES("                . "0, NOW(), '" . session_id() . "')";         mysqli_query($  sql);         session_register("SESS_ORDERNUM");         $  _SESSION['SESS_ORDERNUM'] = mysqli_insert_id();         $  itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES("                    . $  _SESSION['SESS_ORDERNUM'] . ", " . $  _GET['id'] . ", "                     . $  _POST['amountBox'] . ")";         mysqli_query($  itemsql);       }     }     $  totalprice = $  prodrow['price'] * $  _POST['amountBox'] ;     $  updsql = "UPDATE orders SET total = total + "               . $  totalprice . " WHERE id = "               . $  _SESSION['SESS_ORDERNUM'] . ";";     mysqli_query($  updres);     header("Location: " . $  config_basedir . "showcart.php");   } else {     require("header.php");     echo "<form action='addtobasket.php?id="          . $  _GET['id'] . "' method='POST'>";     echo "<table cellpadding='10'>";     echo "<tr>";     if(empty($  prodrow['image']))      {       echo "<td><img src='./productimages/dummy.jpg' width='50' alt='"            . $  prodrow['name'] . "'></td>";     } else {       echo "<td><img src='./productimages/" . $  prodrow['image']            . "' width='50' alt='" . $  prodrow['name']            . "'></td>";     }       echo "<td>" . $  prodrow['name'] . "</td>";       echo "<td>Select Quantity <select name='amountBox'>";       for($  i=1;$  i<=100;$  i++)       {         echo "<option>" . $  i . "</option>";       }       echo "</select></td>";       echo "<td><strong>&pound;"            . sprintf('%.2f', $  prodrow['price'])            . "</strong></td>";       echo "<td><input type='submit' name='submit' value='Add to basket'></td>";       echo "</tr>";       echo "</table>";       echo "</form>";    } } require("footer.php");  ?>