Re: [PHP] Page Refresh

2002-04-23 Thread esivertsen

You could use a SESSION variable called for instance 'SUBMIT_TO_DB'.
After submitting to the database, you simply set this variable 'SUBMIT_TO_DB' to 
'NO'... 
The next time the page is reloaded, you won't have to submit one more time to the 
database, provided you check whether 'SUBMIT_TO_DB' is 'NO'.
And opposite: if it is not set, you SHOULD do the submission to DB. 

My $0.02

Eivind



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




RE: [PHP] Page Refresh

2002-04-23 Thread Crane, Christopher

That is my goal to only use only file and I do use a lot of IF statements.
I will try this. I have not used the Header() function. I will take a look
at it. If you have an example, that would be great.

-Original Message-
From: Justin French [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 10:06 AM
To: Crane, Christopher
Subject: Re: [PHP] Page Refresh
Importance: High


i don't undertand why you have the meta refresh in there, but the porblem
you have is simular to any one who clicks refresh on their browser...

essentialy, what you want to do is after the DB insert, use a header()
redirect to a blank form -- steps might look like:

1. form.php (blank) [click submit]
2. validate.php
   a) if not ok redirect to form.php (with entered data)
   b) if ok, insert into DB  redirect to form.php (blank)

In other words, form.php doesn't actually print any data to the screen, it
just evaluates the entered data, and acts upon it.

The value of this is that if the user never sees validate.php, they can't
refresh it (or have a meta refresh), so the data can't be inserted more than
once via a refresh.

if they refresh the form.php, the DB will not be affected.


If you're cleaver with if() statements and other control structures, you can
actually achieve this effect with only one file (form.php)... but that's
another story :)


Have fun,

Justin French

Creative Director
http://Indent.com.au





on 23/04/02 11:47 PM, Crane, Christopher ([EMAIL PROTECTED]) wrote:

 I use a template page and then split out the middle of the page to do my
PHP
 stuff depending on a variable I pass to it.
 I have a problem I hope someone can help me on.
 The template page has a meta refresh in the header set for 60 secs. One of
 the things this page does is insert data into a MySQL database. The
problem
 is once it is finished it displays the same form used to enter the data in
 the MySql database for another record to be added if you wish...here comes
 the problem. After the first insert, the data form is redisplayed, but
after
 the 60 secs and the refresh takes place it runs the last insert again. If
 the user just leaves that page up, every 60 secs it will insert another
 record every 60 secs.
 
 I was thinking there may be a mechanism to redirect to a different URL
after
 the database insert, but I do not know how to do that. I want to keep the
 meta refresh because there is a lot of dynamic data displayed on the
 template page that changes. Which is the reason for the Meta Refresh to
 begin with...
 
 
 
 Christopher J. Crane
 Network Operations Manager
 
 IKON Office Solutions
 860.659.6464
 
 
 

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