472,125 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 software developers and data experts.

avoid post resubmit on refresh

I've a form wich point to itself in order to check if the compulsory values
are filled. If they are, then I send an email.

Now, I've seen that if you refresh the form (once the email is sent), then
the email is sent again. How to clear the POST values ? I won't the form to
be submitted again. Once the email is sent, then the POST variables should
be blank.

Bob
Jul 17 '05 #1
6 16223
On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote:
I've a form wich point to itself in order to check if the compulsory values
are filled. If they are, then I send an email.


Post the form to a php-only script with all the logic, from there use
header() to go back to the form.
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #2

"Ewoud Dronkert" <fi*******@lastname.net.invalid> a écrit dans le message de
news: ao********************************@4ax.com...
On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote:
I've a form wich point to itself in order to check if the compulsory
values
are filled. If they are, then I send an email.


Post the form to a php-only script with all the logic, from there use
header() to go back to the form.

I HATE this manner. That means that for every page where there is a form,
I've to create an other with the logic. It's already quite difficult to get
a low number of page, but adding every time a new one will kill me (I've
about 80 php pages on my site).

Any other way ?
Jul 17 '05 #3

POST to the same page.

If the result is unsucsessful, show the errors, and allow them to
resubmit.

If the result is successful (page has been processed), use a header to
redirect to the same page with a GET parameter such as success=true,
then just display the "Your Email has been sent!" message.

When it POSTS, it does the processing, when it GETS it displays the
result.

Only downside is you can't echo all the info that the user just typed
in.

For a really long explanation:
http://www.theserverside.com/article...irectAfterPost
---
PHP Stuff:
http://www.douglassdavis.com

Jul 17 '05 #4
Bob Bedford wrote:
"Ewoud Dronkert" <fi*******@lastname.net.invalid> a écrit dans le message de
news: ao********************************@4ax.com...
On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote: <snip> Post the form to a php-only script with all the logic, from there use
header() to go back to the form.

I HATE this manner. That means that for every page where there is a form,
I've to create an other with the logic. It's already quite difficult to get
a low number of page, but adding every time a new one will kill me (I've
about 80 php pages on my site).

Any other way ?


if (the page is GETed)
{
if (!isset($_SESSION['submit_count'][$unique_page_id]))
$_SESSION['submit_count'][$unique_page_id] = 0;
//add hidden "submit_count" in form with a value
$_SESSION['submit_count'][$unique_page_id].
ini_set('url_rewriter.tags', 'form=fakeentry'); //rewrite only the
form
output_add_rewrite_var('submit_count',
$_SESSION['submit_count'][$unique_page_id]);
}
else if (page is POSTed)
{
if
($_SESSION['submit_count'][$unique_page_id]==$_POST['submit_count'])
{
//seems to be ok. Warning: we didn't take care of multiple
form scenario
//stuff to DB
$_SESSION['submit_count'][$unique_page_id] += 1;
}
else
{
//already processed.
}
}

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 17 '05 #5

"www.douglassdavis.com" <do************@earthlink.net> a écrit dans le
message de news: 11**********************@o13g2000cwo.googlegroups. com...

POST to the same page.

If the result is unsucsessful, show the errors, and allow them to
resubmit.

If the result is successful (page has been processed), use a header to
redirect to the same page with a GET parameter such as success=true,
then just display the "Your Email has been sent!" message.

When it POSTS, it does the processing, when it GETS it displays the
result.

Only downside is you can't echo all the info that the user just typed
in.

For a really long explanation:
http://www.theserverside.com/article...irectAfterPost
---
PHP Stuff:
http://www.douglassdavis.com

Thanks for the tip !

Cheers.

Bob
Jul 17 '05 #6

"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> a écrit dans le
message de news: 11**********************@g47g2000cwa.googlegroups. com...
Bob Bedford wrote:
"Ewoud Dronkert" <fi*******@lastname.net.invalid> a écrit dans le message
de
news: ao********************************@4ax.com...
On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote: <snip> Post the form to a php-only script with all the logic, from there use
header() to go back to the form.

I HATE this manner. That means that for every page where there is a form,
I've to create an other with the logic. It's already quite difficult to
get
a low number of page, but adding every time a new one will kill me (I've
about 80 php pages on my site).

Any other way ?


if (the page is GETed)
{
if (!isset($_SESSION['submit_count'][$unique_page_id]))
$_SESSION['submit_count'][$unique_page_id] = 0;
//add hidden "submit_count" in form with a value
$_SESSION['submit_count'][$unique_page_id].
ini_set('url_rewriter.tags', 'form=fakeentry'); //rewrite only the
form
output_add_rewrite_var('submit_count',
$_SESSION['submit_count'][$unique_page_id]);
}
else if (page is POSTed)
{
if
($_SESSION['submit_count'][$unique_page_id]==$_POST['submit_count'])
{
//seems to be ok. Warning: we didn't take care of multiple
form scenario
//stuff to DB
$_SESSION['submit_count'][$unique_page_id] += 1;
}
else
{
//already processed.
}
}

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com
Thanks for the tip !

Cheers.

Bob
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by VB Programmer | last post: by
15 posts views Thread by tmax | last post: by
5 posts views Thread by dennis.mcknight | last post: by
8 posts views Thread by Laith Zraikat | last post: by
1 post views Thread by haj | last post: by
reply views Thread by haj | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.