Note that there are some explanatory texts on larger screens.

plurals
  1. POShow confirmation on referring back to previous page (PHP HTTP REFERER)
    text
    copied!<p>This might be simple but I am having difficulty figuring it out,</p> <p>A form with data in index.php is submitted to sell.php which is processed by mysql query and returns automatically to previous page (index.php) after data is stored in database successfully.</p> <p>The code I am using is:</p> <pre><code>header("Location: " .$_SERVER['HTTP_REFERER']); </code></pre> <p>I needed a little enhancement here. When the page sell.php returns back to index.php, it shall give a confirmation message to user that the data was submitted successfully.</p> <p>index.php</p> <pre><code>&lt;form name="vender" method="post" action="sell.php"&gt; &lt;?php echo $identity; ?&gt; | &lt;?php echo $model; ?&gt; &lt;hr /&gt; &lt;input type="hidden" name="serial" value="&lt;?php echo $identity; ?&gt;" /&gt; &lt;input type="hidden" name="model" value="&lt;?php echo $model; ?&gt;" /&gt; &lt;input type="hidden" name="date" value="&lt;?php echo DATE('Y-m-d'); ?&gt;" /&gt; &lt;table style="font-size: 8pt;"&gt; &lt;tr&gt;&lt;td&gt;IEMI:&lt;/td&gt;&lt;td&gt;&lt;input class="form-sell" type="text" name="imei" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Nombre: &lt;/td&gt;&lt;td&gt;&lt;input class="form-sell" type="text" name="name" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Contacto: &lt;/td&gt;&lt;td&gt;&lt;input class="form-sell" type="text" name="contact" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;NIF: &lt;/td&gt;&lt;td&gt;&lt;input class="form-sell" type="text" name="nif" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Cantidad: &lt;/td&gt;&lt;td&gt;&lt;input class="form-sell" type="text" name="qty" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Precio: &lt;/td&gt;&lt;td&gt;&lt;input class="form-sell" type="text" name="price" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="submit" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>sell.php</p> <pre><code>&lt;?php include "connect.php"; include "links.php"; $date = $_POST['date']; $serial = $_POST['serial']; $model = $_POST['model']; $imei = $_POST['imei']; $name = $_POST['name']; $contact = $_POST['contact']; $nif = $_POST['nif']; $qty = $_POST['qty']; $price = $_POST['price']; mysql_query("INSERT INTO mobile_sell_data(date,serial,model,imei,name,contact,nif,qty,price) VALUES('$date','$serial','$model','$imei','$name','$contact','$nif','$qty','$price')"); mysql_query("UPDATE mobils SET qty=qty-'$qty' WHERE id = '$serial'"); header("Location: " .$_SERVER['HTTP_REFERER']); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload