.......................
My multipurpose PHP page shows all feedback letters to the website - by default.
At the bottom of this page an <a> element lets the user recall this page – only now the page only displays the form for user feedback.
Simple "If" logic accomplishes this (Either display all letters, or display just the input form).
The problem is: The user may retrieve and re-submit his data repeatedly - simply by hitting the browser's "back" button and resubmitting the form.
To prevent this potential data abuse, I need to erase the form's original input, right after the database update.
I think for this I need access to the DOM. But javascript’s onload event handler won’t cut it because the 1st time the page loads the IF logic prevents the FORM structure in the DOM to be invoked.
Here's my code’s skeletal structure within the page's body element. Someone suggested “cookies” but without more specifics, I’m still lost.
<?php
if (isset($_GET['userInput'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Type your input here:<textarea name="ltrtext" rows="10" cols="40"></textarea></label>
<input type="submit" value="Submit" />
</form>
<?php
} else {// -- Default Page Display --
// I connect to database
// Insert feedback (if any) into the database
// I display all feedback letters
// And here, at the end of the list, I let the user trigger display of the feedback form
echo '<p><a href="' . $_SERVER['php_self'] . '?userInput=1">Add Your Input!</a></p>';
}
?>
My multipurpose PHP page shows all feedback letters to the website - by default.
At the bottom of this page an <a> element lets the user recall this page – only now the page only displays the form for user feedback.
Simple "If" logic accomplishes this (Either display all letters, or display just the input form).
The problem is: The user may retrieve and re-submit his data repeatedly - simply by hitting the browser's "back" button and resubmitting the form.
To prevent this potential data abuse, I need to erase the form's original input, right after the database update.
I think for this I need access to the DOM. But javascript’s onload event handler won’t cut it because the 1st time the page loads the IF logic prevents the FORM structure in the DOM to be invoked.
Here's my code’s skeletal structure within the page's body element. Someone suggested “cookies” but without more specifics, I’m still lost.
<?php
if (isset($_GET['userInput'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Type your input here:<textarea name="ltrtext" rows="10" cols="40"></textarea></label>
<input type="submit" value="Submit" />
</form>
<?php
} else {// -- Default Page Display --
// I connect to database
// Insert feedback (if any) into the database
// I display all feedback letters
// And here, at the end of the list, I let the user trigger display of the feedback form
echo '<p><a href="' . $_SERVER['php_self'] . '?userInput=1">Add Your Input!</a></p>';
}
?>