I have a script that posts form responses to a MySQL Database. However, it is on occasion posting twice to the table with seconds between each row.
Here is the handling script:
if (isset($_POST['SignIn']))
{
$Name = $_POST['Name'];
$Sleep = $_POST['Sleep'];
$Soreness = $_POST['Soreness'];
$Fatigue = $_POST['Fatigue'];
$Energy = $_POST['Energy'];
$Stress = $_POST['Stress'];
$Total = $Sleep + $Soreness + $Fatigue + $Energy + $Stress;
$Comments = $_POST['Comments'];
$sql = "
INSERT INTO
YDP_Wellbeing (Name, Sleep, Soreness, Fatigue, Energy, Stress, Total, Comments)
VALUES
('$Name', $Sleep, $Soreness, $Fatigue, $Energy, $Stress, $Total, '$Comments')";
if (mysqli_query($con, $sql))
{
$_SESSION['alert-type'] = 'success';
$_SESSION['alert-head'] = 'Welcome!';
$_SESSION['alert-body'] = 'Thank You <strong>' . $Name . '</strong> You\'re Response Has Been Submitted.';
header("location: index.php");
}
else
{
echo "Failed: " . mysqli_error($con);
}
}
Sometimes it posts once, other times it posts twice, so the issue is intermittent it would appear?