If I insert a new record into the database via PHP and then click the submit button and then each time I refresh the page it inserts the recently added record into the database. How do I stop this from happening? I don't want to redirect to another form after the submit button too. The weird thing is, if I click the submit button twice and then refresh the form it doesn't insert duplicates into the database. Why is this? Please help :/ thanks
Here's the code:
<div class="insertDiv">
<form method="POST" action="contracts.php">
<?php
if(empty($_POST['ContractDate']) && empty($_POST['ComputerId2']) && empty($_POST['CustomerId']) && empty($_POST['ContractLevel']))
{
}
else
{
include("dbinfo.inc.php");
$comm=@mysql_connect(localhost,$username,$password);
$rs=@mysql_select_db($database) or die( "Unable to select database");
$contractDate=$_POST['ContractDate'];
$computerID=$_POST['ComputerId'];
$customerID=$_POST['CustomerId'];
$contractLevel=$_POST['ContractLevel'];
$sql="INSERT INTO contract VALUES ('','$contractDate','$computerID', '$customerID', '$contractLevel')";
$result=mysql_query($sql)or die("Insert Error: ".mysql_error());
mysql_close();
}
?>
<div class = "myButton">
Insert
</div>
<p></p>
Enter contract start date: 
<input type="date" name="ContractDate" size=30 class="input"><br><br>
Enter computerID: 
<input type="text" name="ComputerId" size=30 class="input"><br><br>
Enter customerID: 
<input type="text" name="CustomerId" size=30 class="input"><br><br>
Enter contract level: 
<input type="text" name="ContractLevel" size=30 class="input"><br><br>
<input type="reset" value="Reset" class="button">    
<input type="submit" value="Submit" class="button">
</form>
</div>