Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When PHP interferes with the DOM (dilemma)

Status
Not open for further replies.

ruffy

Programmer
Oct 1, 2003
72
US
Here's my problem.

My multipurpose PHP page has "If" logic around a FORM element, to prevent the FORM from display unless the user hits a "Send Feedback" button.

But the user can retrieve and re-submit his data numerous times - 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 text the user originally submitted. For this I need access to the DOM. But the DOM is not available, because when the window loaded the form was NOT yet invoked.

Any ideas?
.
 
Using PHP cookie the user after form submission. Then using onLoad and Javascript allow the form to be submitted only if the cookie doesn't exist.

M. Brooks
 
Before running the submission code in your PHP check for the presence of your cookie, if it is not there then do the submission and set your cookie. This can all be done server-side and means you don't have to try to capture client-side events that aren't there when the user presses a back button.

 
Can you be more specific? Where would the cookie help?
Please remember, I only display the FORM if the user requests it. Otherwise the page only displays all the feedback.

Here's how my code is structured within the page's body:


<?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 the feedback (if any) into the database
// I display all feedback
// And here - I let the user trigger display of the feedback form
echo '<p><a href="' . $_SERVER['php_self'] . '?userInput=1">Add Your Input!</a></p>';
}
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top