When I refresh my page, duplicate entries are entered into my MYSQL database via a form submission.
Anyway to prevent this?
Here's my form:
<form action="index.php" method="POST">
<input type="text" name="GoodComment" maxlength="140" class="textBox">
<input type="submit" class="button">
</form>
<div id="good">
<?php
fetchGood();
?>
</div>
Here's my INSERT code.
function fetchGood() {
/*** INSERT data ***/
$goodComment = $_POST['GoodComment'];
$count = $db->prepare("INSERT INTO ProSubmissions(Comments) VALUES(?)");
$count->execute(array($goodComment));
/*** close the database connection ***/
$db = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}