I have a button that acts as a submit:
<button id='bet_horse' name='bet_horse' type="submit" class='btn btn-default bet_btn' >
Submit This Info
</button>
And a way for the post to be handled:
if ($_POST) {
$countInserts = 0;
if (isset($_POST['bet_horse'])) {
if ($countInserts < 1) {
$bs->insertbet_betslip(
'horse',
$current_user2->ID,
mysql_real_escape_string($_POST['nameMarket']),
mysql_real_escape_string($_POST['nameType']),
$_POST['p_name'], 0,
$_POST['odds'],
$_POST['bettilltime'],
$_POST['bettilldate'],
date("H:i:s", time()),
date("Y-m-d"),
is_user_logged_in() ? true : false
);
}
//header("Location: /"); //This cannot be done becaause headers are already sent.
}
But after this I need to be able to stop the post from posting, the only ways I found of doing this is shown in the comment in the code, however I could not do this because of a lot of background WordPress processes, another way I thought to do it was with the if ($countInserts < 1 ) { }
, but again didn't work, I have seacrhed for an answer but have been unsucessful, can anybody help?