I am developing a courier application using PHP and MySQL and I have come across a minor bug. Say, I have a page that adds a new shipment (add.php). Upon filling the details and clicking on "submit" button in the form, addshipment.php is fired which contains the code to add the new shipment to the sql table. If the data is entered successfully, the following code will execute:
header("location:add.php?add=success");
Thus, the add.php page will reload with the URL "add.php?add=success"
with an alert box that will say that data has been inserted successfully. That alert box is executed via the following code at the bottom of the page:
if(isset($_GET['add']))
{
switch($_GET['add'])
{
case "invalid":
echo "<script>alert('Please fill all the fields');</script>";
break;
case "fail":
echo "<script>alert('Your data was not inserted successfully');</script>";
break;
case "success":
echo "<script>alert('Your Data was Added Successfully');</script>";
break;
}
}
Works fine but every time I refresh the page I get the same alert box since the URL still contains ?add=success
. I wish the add.php page not to contain the values after data insertion but still display the alert message. Any ideas?
Thanks