
Originally Posted by
I am Abby
after hitting the submit the code should run...otherwise not.
The first time you run this...it does not run. If you hit the submit and the page sends the data back to itself it works correctly. After that if you refresh the page I don't want it to work.
That's the problem: if you click Refresh, the browser usually resubmits the POST information. You can avoid this by automatically redirecting the page (you could even simply redirect it to itself) - then if the user refreshes, he'll be refreshing the new page, not the one that just submitted the form. You have to do this before you output anything, so you'll have to pass the information along somehow.
(not tested)
PHP Code:
<?php
// if the form was submitted, process the input
if (isset($_POST['Quote']))
{
$newcount = $_POST['Quote'] = 1;
// instead of echoing the value, redirect ("refresh") the page
// and pass the value as a query string
header('Location: '.$_SERVER['PHP_SELF'].'?newcount='.$newcount);
}
// if the form was not just submitted (no $_POST['Quote'])
elseif(isset($_GET['newcount']))
{
// if the query string is present, echo the value
echo $_GET['newcount'];
}
// you could also use sessions.
?>
Bookmarks