Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Reply
 
Topic Tools
  #1  
Old November 2nd, 2007, 12:43 AM
FrEaKmAn FrEaKmAn is offline
Senior Member
 
Join Date: Aug 2005
Posts: 477
posting form

Hi,

I have one simple question. So if we have simple form with post method, something like

PHP Code:
<?php
if($_POST[submit]){
   
//execute code
}
?>
<form action="index.php" method="post">
<input name="test">
<input name="submit" value="submit" type="submit">
</form>
and when we submit it and try to refresh, at least as I know, we get warning about submitting data again and if we confirm, it will resubmit. Now how can I remove this? How to protect it from resubmitting...
Reply With Quote
  #2  
Old November 2nd, 2007, 01:07 AM
Buzz's Avatar
Buzz Buzz is offline
Cyber Tech Help Moderator
 
Join Date: Sep 2000
O/S: MacOS
Location: Oregon, USA
Posts: 3,362
Use a second php page for form submissions. Basically action="submit.php"

At the end of submit.php redirect back to the form page with a message for confirmation or error.

Essentially the user never sees submit.php it just processes the form then throws them back to the form. Since there's no form processing on the form, you wont' get the warning about resubmitting.
__________________
Scott
Moderator : Macintosh : Website & Graphics
Adobe Certified Expert: Illustrator
Royalty-Free Vector Stock Art
Reply With Quote
  #3  
Old November 2nd, 2007, 02:00 AM
FrEaKmAn FrEaKmAn is offline
Senior Member
 
Join Date: Aug 2005
Posts: 477
it's possible, but I hate that in this case I would need to create new page for each form. But what would back button do in this case?
Reply With Quote
  #4  
Old November 2nd, 2007, 05:21 AM
Buzz's Avatar
Buzz Buzz is offline
Cyber Tech Help Moderator
 
Join Date: Sep 2000
O/S: MacOS
Location: Oregon, USA
Posts: 3,362
You can create 1 page and use different post variable for each form. Not 100% certain about back button behavior. Theoretically it would simply show the form before it was submitted.

Another option is to simply clear all post variables after processing the form.
__________________
Scott
Moderator : Macintosh : Website & Graphics
Adobe Certified Expert: Illustrator
Royalty-Free Vector Stock Art
Reply With Quote
  #5  
Old November 2nd, 2007, 10:27 AM
FrEaKmAn FrEaKmAn is offline
Senior Member
 
Join Date: Aug 2005
Posts: 477
how would I clean them? I can't just do:

PHP Code:
$_POST[submit]=0
Reply With Quote
  #6  
Old November 2nd, 2007, 12:38 PM
Buzz's Avatar
Buzz Buzz is offline
Cyber Tech Help Moderator
 
Join Date: Sep 2000
O/S: MacOS
Location: Oregon, USA
Posts: 3,362
PHP Code:
$_POST['submit'] =""
__________________
Scott
Moderator : Macintosh : Website & Graphics
Adobe Certified Expert: Illustrator
Royalty-Free Vector Stock Art
Reply With Quote
Reply

Bookmarks

Topic Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:31 AM.

[ RSS ]