Page refresh and database updation

Page refresh and database updation

am 26.09.2006 14:31:12 von ptamkhane

Hi All,
I am a PHP newbie. I am using HTTP POST request to send some data to Apache and then using MySql to store that information. Once
information is stored in MySql DB successfully, I display a result page. But the problem I am facing is that, if I refresh the
result page displayed after database updation, the information is stored again in database which I don't want to. Please guide me on
how I can avoid duplication of information in database on refreshing the page. Thanks in advance!

Regards,
Pravin

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Page refresh and database updation

am 26.09.2006 14:42:53 von Brad Bonkoski

I'm sure there are many ways...
a few off the top of my head.
a). if there is some field or combination of fields that guarantee
uniqueness then you can test for their existence before you insert.
b). When you insert the first time set some session variable to
something, and then don't insert if that session variable exists.
c). have some middle page that does your insertion and then immediately
redirects to another page which displays results, but has not more POST
data associated with it, so refreshing that page will not cause a
re-post of your data.

HTH
-B

Tamkhane, Pravin wrote:
> Hi All,
> I am a PHP newbie. I am using HTTP POST request to send some data to
> Apache and then using MySql to store that information. Once
> information is stored in MySql DB successfully, I display a result
> page. But the problem I am facing is that, if I refresh the result
> page displayed after database updation, the information is stored
> again in database which I don't want to. Please guide me on how I can
> avoid duplication of information in database on refreshing the page.
> Thanks in advance!
>
> Regards,
> Pravin

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Page refresh and database updation

am 26.09.2006 14:45:14 von Sancar Saran

On Tuesday 26 September 2006 15:31, Tamkhane, Pravin wrote:
> Hi All,
> I am a PHP newbie. I am using HTTP POST request to send some data to Apache
> and then using MySql to store that information. Once information is stored
> in MySql DB successfully, I display a result page. But the problem I am
> facing is that, if I refresh the result page displayed after database
> updation, the information is stored again in database which I don't want
> to. Please guide me on how I can avoid duplication of information in
> database on refreshing the page. Thanks in advance!
>
> Regards,
> Pravin

Hi,

Store last postted data into some where in $_SESSION (for example
$_SESSION['last']) then, when user posts a data. check the last posted data
if there are same data reject to record db if not record data to db.

for example (I assume your form field names uses name='postf[fieldName])

Your Php code ...
$process = 'pass';
if(is_array($_SESSION['last'])
{
if($_SESSION['last']['fieldName'] == $_REQUEST['postf']['fieldName'])
{
$strProcess = 'stop';
}
... put there other fields
}

if($process == 'pass')
{
do your sql statement
$_SESSION['last'] = $_REQUEST['postf'];
}

Regards

Sancar

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Page refresh and database updation

am 26.09.2006 15:04:39 von RaJeSh VeNkAtA

Hi,
one thing u can do is u can have a primary key the table you are
inserting so that duplication wont be done.
If thats not possible redirect the page to the results page
after updating the post data than showing him the results in the action page ( action i mean where the form
action has been written )

raj



On Tue, 26 Sep 2006, Tamkhane, Pravin wrote:

> Hi All,
> I am a PHP newbie. I am using HTTP POST request to send some data to Apache
> and then using MySql to store that information. Once information is stored in
> MySql DB successfully, I display a result page. But the problem I am facing
> is that, if I refresh the result page displayed after database updation, the
> information is stored again in database which I don't want to. Please guide
> me on how I can avoid duplication of information in database on refreshing
> the page. Thanks in advance!
>
> Regards,
> Pravin
>

--

The secret to creativity is knowing how to hide your sources.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Page refresh and database updation

am 26.09.2006 16:30:00 von Chuck Stearns

Tamkhane, Pravin wrote:
> Hi All,
> I am a PHP newbie. I am using HTTP POST request to send some data to
> Apache and then using MySql to store that information. Once information
> is stored in MySql DB successfully, I display a result page. But the
> problem I am facing is that, if I refresh the result page displayed
> after database updation, the information is stored again in database
> which I don't want to. Please guide me on how I can avoid duplication of
> information in database on refreshing the page. Thanks in advance!
>
> Regards,
> Pravin
You probly want to use a seperate script to build the results, or even a
PEAR template mechanism.

/cs

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Re: Page refresh and database updation

am 26.09.2006 18:12:39 von php

You can redirect the page to the result page after the data is saved, using header("Location: successpage.php"). I've used this on several sites. It's a little extra work but does prevent the reposting of data.

Another option is to use AJAX to send the data to the webserver and then have the javascript open the result page after the update is complete. I do this on several of my webpages and it works great.

>Tamkhane, Pravin wrote:
>> Hi All,
>> I am a PHP newbie. I am using HTTP POST request to send some data to
>> Apache and then using MySql to store that information. Once information
>> is stored in MySql DB successfully, I display a result page. But the
>> problem I am facing is that, if I refresh the result page displayed
>> after database updation, the information is stored again in database
>> which I don't want to. Please guide me on how I can avoid duplication of
>> information in database on refreshing the page. Thanks in advance!
>>
>> Regards,
>> Pravin
>You probly want to use a seperate script to build the results, or even a
>PEAR template mechanism.
>
>/cs
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php