<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Refresh form but do not resubmit (PHP)</title>
	<atom:link href="http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/</link>
	<description>I fix stuff</description>
	<lastBuildDate>Wed, 11 Jan 2012 23:36:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ivan Panchev</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-17060</link>
		<dc:creator>Ivan Panchev</dc:creator>
		<pubDate>Fri, 17 Jun 2011 18:56:43 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-17060</guid>
		<description>I believe this is the code:

 file 1 -  with the submission form
form ... action=&quot;file2.php?submit=true&gt;
...
&lt;/form

file 2 - with the code that updates the database
</description>
		<content:encoded><![CDATA[<p>I believe this is the code:</p>
<p> file 1 &#8211;  with the submission form<br />
form &#8230; action=&#8221;file2.php?submit=true&gt;<br />
&#8230;<br />
&lt;/form</p>
<p>file 2 &#8211; with the code that updates the database</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Panchev</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-17059</link>
		<dc:creator>Ivan Panchev</dc:creator>
		<pubDate>Fri, 17 Jun 2011 18:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-17059</guid>
		<description>Thank You Anna this is verry good(the best) solution :).  Sessions are not good in this case. They can produce great pain. So:

&lt;!-- file 1 -  with the submission form --&gt; 

...


&lt;!-- file 2 - with the code that updates the database --&gt;


I believe this is it. Great! I&#039;ll try it now :)</description>
		<content:encoded><![CDATA[<p>Thank You Anna this is verry good(the best) solution <img src='http://annafilina.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  Sessions are not good in this case. They can produce great pain. So:</p>
<p><!-- file 1 -  with the submission form --> </p>
<p>&#8230;</p>
<p><!-- file 2 - with the code that updates the database --></p>
<p>I believe this is it. Great! I&#8217;ll try it now <img src='http://annafilina.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mehdi Hanbali</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-7853</link>
		<dc:creator>Mehdi Hanbali</dc:creator>
		<pubDate>Mon, 13 Dec 2010 16:33:10 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-7853</guid>
		<description>Great idea Anna.  I&#039;ve read in other places about using redirect, but not with the appending of that variable.  To elaborate, here is one way you can do it.

In your form have it something like: 

At the very top of your php page, before anything is outputted to the screen do something like:

    $old_submit = $_GET[&#039;submit&#039;]; // this gets the submit variable you appended in your form
    $current_url = &#039;samepage.php&#039;
    if ($old_submit == &quot;true&quot;) {
        header(&quot;Location: $current_url&quot;);
        $old_submit = &quot;false&quot;;
    }

Let me know if you have any questions or better ways of doing it.

-Mehdi (letdev DOT com - launching december 17th, 2010)</description>
		<content:encoded><![CDATA[<p>Great idea Anna.  I&#8217;ve read in other places about using redirect, but not with the appending of that variable.  To elaborate, here is one way you can do it.</p>
<p>In your form have it something like: </p>
<p>At the very top of your php page, before anything is outputted to the screen do something like:</p>
<p>    $old_submit = $_GET['submit']; // this gets the submit variable you appended in your form<br />
    $current_url = &#8217;samepage.php&#8217;<br />
    if ($old_submit == &#8220;true&#8221;) {<br />
        header(&#8220;Location: $current_url&#8221;);<br />
        $old_submit = &#8220;false&#8221;;<br />
    }</p>
<p>Let me know if you have any questions or better ways of doing it.</p>
<p>-Mehdi (letdev DOT com &#8211; launching december 17th, 2010)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: omer</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-6644</link>
		<dc:creator>omer</dc:creator>
		<pubDate>Fri, 29 Oct 2010 17:51:36 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-6644</guid>
		<description>i didnt get it :)</description>
		<content:encoded><![CDATA[<p>i didnt get it <img src='http://annafilina.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: php thumbnailer</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-3376</link>
		<dc:creator>php thumbnailer</dc:creator>
		<pubDate>Fri, 21 May 2010 16:48:38 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-3376</guid>
		<description>I am using sessions too to avoid that.</description>
		<content:encoded><![CDATA[<p>I am using sessions too to avoid that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-3041</link>
		<dc:creator>andrew</dc:creator>
		<pubDate>Tue, 04 May 2010 03:09:27 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-3041</guid>
		<description>Hi Anna have you got a code example you could share, am a newibe and not sure I can picture it right.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi Anna have you got a code example you could share, am a newibe and not sure I can picture it right.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anna</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-1982</link>
		<dc:creator>Anna</dc:creator>
		<pubDate>Mon, 08 Feb 2010 19:07:43 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-1982</guid>
		<description>Sorry for the late response.

The problem with storing your data in the session for every post is that it&#039;s an extra operation that has no real value and can be easily avoided. Also, when you have multiple tabs open with the same form, you may get unexpected results. Last, there may be some data that you would never for the world want to store in a session, such as a password or a credit card number, because they will be unencrypted and in a vulnerable session file (unless your sessions are in DB, but you still have the encryption issue).

Redirection after the post data has been processed is a standard approach used by many renowned PHP frameworks that I have worked with since I posted this article.</description>
		<content:encoded><![CDATA[<p>Sorry for the late response.</p>
<p>The problem with storing your data in the session for every post is that it&#8217;s an extra operation that has no real value and can be easily avoided. Also, when you have multiple tabs open with the same form, you may get unexpected results. Last, there may be some data that you would never for the world want to store in a session, such as a password or a credit card number, because they will be unencrypted and in a vulnerable session file (unless your sessions are in DB, but you still have the encryption issue).</p>
<p>Redirection after the post data has been processed is a standard approach used by many renowned PHP frameworks that I have worked with since I posted this article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juan</title>
		<link>http://annafilina.com/blog/refresh-form-but-do-not-resubmit-php/comment-page-1/#comment-1950</link>
		<dc:creator>Juan</dc:creator>
		<pubDate>Fri, 05 Feb 2010 14:08:34 +0000</pubDate>
		<guid isPermaLink="false">http://annafilina.com/blog/archives/11#comment-1950</guid>
		<description>Hi,

I was trying to deal with this matter but I gave up as I could not understand it properly.

The solution I have seen is related to the session. when you submit a form then you save the values in a session and then empty the values in the form so the page will not resend the values again when it is refreshed. 

Now I am seeing in your blog that this solution would not be good enough.

I would appreciate if you may explain me this problem.

Thanks a lot,

Juan</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I was trying to deal with this matter but I gave up as I could not understand it properly.</p>
<p>The solution I have seen is related to the session. when you submit a form then you save the values in a session and then empty the values in the form so the page will not resend the values again when it is refreshed. </p>
<p>Now I am seeing in your blog that this solution would not be good enough.</p>
<p>I would appreciate if you may explain me this problem.</p>
<p>Thanks a lot,</p>
<p>Juan</p>
]]></content:encoded>
	</item>
</channel>
</rss>

