473,385 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 16327
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
1
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? ...
4
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
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...
0
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()...
5
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...
8
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...
1
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.