Re: Page refresh and database updation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux