title: Submit form from a PHP HTML table
body: <p>Supposed to have fetch data from a database, and display on a table. On every record is a text box where one can insert a receipt number and submit. On submit, the receipt number should be inserted on a database for that record and the page reloads displaying the inserted record instead of a text field. I'm not sure what I;m doing wrong because the page loads to a blank page.  </p>
  
  <pre><code>$sql = "SELECT * FROM customer";
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
  
       echo " &lt;table&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;
  &lt;th&gt;Amount&lt;/th&gt;&lt;th&gt;TransactionID&lt;/th&gt;&lt;th&gt;Mobile Number&lt;/th&gt;
  &lt;th&gt;Time Paid&lt;/th&gt;&lt;th&gt;Account&lt;/th&gt;
  &lt;th&gt;Receipt Number&lt;/th&gt;&lt;/tr&gt;";
  
       // output data of each row
       while($row = $result-&gt;fetch_assoc()) {
        echo "&lt;tr&gt;&lt;td&gt;" . $row["id"]. "&lt;/td&gt;
   &lt;td&gt;" . $row["name"]. "&lt;/td&gt;&lt;td&gt;" . $row["amount"]. "&lt;/td&gt;
   &lt;td&gt;" . $row["trans_id"]. "&lt;/td&gt;&lt;td&gt;" . $row["msisdn"]. "&lt;/td&gt;
  &lt;td&gt;" . $row["time_paid"]. "&lt;/td&gt;
  &lt;td&gt;" . $row["status"]. "&lt;/td&gt;
  &lt;td&gt;&lt;form action= 'receipt.php' method='post'&gt;
      &lt;input type ='text' name='receipt'&gt;
      &lt;input type ='hidden' name='hidden' value='".$row["receipt"]."'&gt;
      &lt;input type='submit' name='submit' value='submit'&gt;&lt;/td&gt;&lt;/form&gt;&lt;/tr&gt;";
   }
   echo "&lt;/table&gt; ";
  
  
   // receipt.php
  
   if(isset($_POST['submit']))
    {
  
   //connection
  
   $sql = "INSERT INTO customer (receipt, date_entered) VALUES ('" . $_POST['receipt'] . "','NOW()')";
  
  
   if ($conn-&gt;query($sql) === TRUE) {
  
     // echo "New record created successfully";
   } else {
      echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
   }
  
   $conn-&gt;close(); 
  
  
   header('Location: http://localhost/com/payf.php');
   }
    else {
      echo "Please Enter the Receipt Number";
      header('Location: http://localhost/com/payf.php');
    }
  </code></pre>