Every time i refresh page it inserts same user into database

By Kolibrok

Here is PHP code

$userName = stripslashes($userName);
$password = stripslashes($password);
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "123";
$mysql_databse = "websiteusers";
$prefix = "";
$bd = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
$sql = "INSERT INTO websiteusers
       VALUES ( '$firstname', '$lastname','$userName', '$email','$password')";
$retval = mysqli_query($bd,$sql );
if(! $retval )
  die('Could not enter data: ');
  return false;
else {echo "Entered data successfullyn";
   $usernamecheck=mysqli_query($bd,"SELECT `userName` FROM `websiteusers`
                             WHERE userName='$userName'");
   echo $userName." is already taken";
 return false;
 }header("Location: Main.php");}

User registers then when he is in his profile page as soon as he refreshes it inserts same username again.And also username and email are unique in my dt it cant insert it and gives an error

Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273