473,685 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16338
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*******@last name.net.invali d> 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*******@last name.net.invali d> 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($_SESSI ON['submit_count'][$unique_page_id]))
$_SESSION['submit_count'][$unique_page_id] = 0;
//add hidden "submit_cou nt" in form with a value
$_SESSION['submit_count'][$unique_page_id].
ini_set('url_re writer.tags', 'form=fakeentry '); //rewrite only the
form
output_add_rewr ite_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.douglassda vis.com" <do************ @earthlink.net> a écrit dans le
message de news: 11************* *********@o13g2 00...legr oups.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**********@r ediffmail.com> a écrit dans le
message de news: 11************* *********@g47g2 00...legr oups.com...
Bob Bedford wrote:
"Ewoud Dronkert" <fi*******@last name.net.invali d> 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($_SESSI ON['submit_count'][$unique_page_id]))
$_SESSION['submit_count'][$unique_page_id] = 0;
//add hidden "submit_cou nt" in form with a value
$_SESSION['submit_count'][$unique_page_id].
ini_set('url_re writer.tags', 'form=fakeentry '); //rewrite only the
form
output_add_rewr ite_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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1659
by: shawn | last post by:
I'm editing existing code, where the user selects an item on Page1.asp and clicks submit. Page1 then calls Page2.asp which subsequently runs a query to validate the data selected (passed) from Page1. If it is duplicate data, a Javascript alert box is invoked, once the user the clicks "ok" on the alert Javascript attempts to redirect back to Page1 (so the user can reselect) but this process is halted by the browser ("The page you requested was...
1
1472
by: davidw | last post by:
This troubles me for a while. When user click back button and click submit button, I get the same data as user click refresh(it resubmit the page too). Is there a way to tell the difference? thanks.
4
2944
by: VB Programmer | last post by:
Can someone provide a simple explanation on the difference between the GET and POST methods? What are the adv/disadv of both and when should I use them? Thanks.
15
33383
by: tmax | last post by:
PHP Pros: I have a simple html form that submits data to a php script, which processes it, and then redisplays the same page, but with a "thank you" message in place of the html form. This is all working fine. However, when refresh the browser, I get the following message displayed: "The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out (such as as search or online purchse) will...
0
1381
by: Jeyakumar | last post by:
Hi, I am using following code to avoid security warning when switch from pageA(https) to PageB (http). 'Output a redirector for the needed page to avoid a security warning. Response.Clear() 'Add a refresh header to the response for the new path. Response.AddHeader("Refresh", "0;URL=PageB.aspx")
5
4475
by: dennis.mcknight | last post by:
I've created a simple guestbook and register user page, however when they are used and then re used quickly after, php doesn't seem to be getting the POST info again. For instance, if a user posts a message in the guestbook and then immediately posts another message, the 2nd POST is not working if it happens in under about 10 seconds (is my best estimate). So my question is: is there some type of timeout or variable that is preventing...
8
3505
by: Laith Zraikat | last post by:
I am trying to invoke a post request from code behind of an asp.net page using "WebClient" object, and I want the user to be redirected to the action url as well. So far Ive been able to send the post and get the response. using this code: Dim PostData as string Dim ActionURL as string Dim myWebClient As WebClient = New WebClient
1
1130
by: haj | last post by:
I have iframes in my page its load pdf file. when i refresh or any server event happen in the page pdf get refreshed and it show first page of pdf. i want to avoid pdf refresh. please help me out this problem.
0
904
by: haj | last post by:
I have iframe in my page its load pdf file. when ever server event happen the iframes pdf get refreshed and its show first page of pdf. i want to avoid the pdf refresh and should show same page of pdf as it show before refresh.
0
8577
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8507
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8926
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7589
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4302
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.