stop inserting data in the database when refreshing the page

<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>Untitled Document</title>
</head>

<body>
<?php include(“header.php”);?>
<h3>thanks for submitting the user record</h3>
<p>if you want to enter new user record click below</p>
<a href=”add.php”>click here</a>
<?php include(“admin_info.php”);?>
<?php

$firstname = $_POST[‘f_name’];

$lastname=$_POST[‘l_name’];
$cnic = $_POST[‘cnic’];
$cell_no=$_POST[‘cell_no’];
$h_address=$_POST[‘h_address’];

// escape variables for security

$firstname = mysqli_real_escape_string($connect, $_POST[‘f_name’]);
$lastname=mysqli_real_escape_string($connect,$_POST[‘l_name’]);
$cnic=mysqli_real_escape_string($connect,$_POST[‘cnic’]);
$cell_no=mysqli_real_escape_string($connect,$_POST[‘cell_no’]);
$h_address=mysqli_real_escape_string($connect,$_POST[‘h_address’]);
$b_address=mysqli_real_escape_string($connect,$_POST[‘b_address’]);
$email=mysqli_real_escape_string($connect,$_POST[’email’]);
$asset_name=mysqli_real_escape_string($connect,$_POST[‘asset_name’]);
$asset_value=mysqli_real_escape_string($connect,$_POST[‘asset_value’]);
$advance=mysqli_real_escape_string($connect,$_POST[‘advance’]);
$tenure=mysqli_real_escape_string($connect,$_POST[‘tenure’]);
$installment=mysqli_real_escape_string($connect,$_POST[‘installment’]);
$guaranteer_address=mysqli_real_escape_string($connect,$_POST[‘guaranteer_address’]);

$guaranteer_no=mysqli_real_escape_string($connect,$_POST[‘guaranteer_no’]);

$sql=”INSERT INTO user_info (f_name,l_name,cnic,cell_no,h_address,b_address,email,asset_name,asset_value,advance,tenure,installment,guaranteer_address,guaranteer_no)
VALUES (‘$firstname’, ‘$lastname’,’$cnic’,’$cell_no’,’$h_address’,’$b_address’,’$email’,’$asset_name’,’$asset_value’,’$advance’,’$tenure’,’$installment’,’$guaranteer_address’,’$guaranteer_no’)”;

//best outside the if statement so user isn’t stuck on a white blank page.

$retval = mysqli_query($connect,$sql);
if(! $retval )
{
  echo “data is not submitted”.mysql_error();
 

}
else{
    echo “successfully”;
    mysqli_close($connect);
    header(“location:add.php”);

//after closing your connection, move your header to location that ‘s way user cannot upload data again and again
    
}

?>

</body>
</html>