I am creating a Posting system like facebook. But when I am going to store my data in MySQL database, this problem is got. Every time I reload the page, my last post is being saved again and again automatically. Here is my code
<?php
$con= mysqli_connect("sql103.ezyro.com", "ezyro_24157515", "fq3850whf75pj5", "ezyro_24157515_Leash");
if(isset($_POST['Launch'])) {
$title= $_POST['title'];
$desc= $_POST['desc'];
$date=date("Y-m-d h:i:sa");
$users= $_SESSION['username'];
$q= "INSERT INTO `leashes` (`id`, `user_name`, `title`, `description`, `date_time`)
VALUES('','".$users."', '".$title."', '".$desc."', '".$date."')";
$r= mysqli_query($con, $q);
if($r){
echo 'Done';
}else{
echo $q;
}
}
?>
I have a login system from where I get the user's name. Please help me to overcome this problem.