![]() |
|
#1
|
|||
|
|||
Refresh page without changing anything in the pageI write HTML and use 'form' to post data to next page. In next page, I $_POST[] data and store into database, it should be done for this process. But if I click "refresh button", the data will be posted from last page again, and also store the data into database, that will duplicate data, which is not what I want. so How can I do? Any good idea.
|
|||
|
#2
|
||||
|
||||
Re: Refresh page without changing anything in the pageI usually handle that situation by keeping a session variable, formID, which increments every time a form is submitted. Every form also has a hidden formID input. When the form is submitted, the php script that processes the form data checks if the formID value from the form matches the session variable. This works because when you refresh a form, the hidden formID that is reposted no longer matches the session variable, since the session variable would have been incremented the first time the form was submitted.
Here's a simple example. In your HTML form: HTML Code:
And in the php script that processes the form: PHP Code:
You'll need to initialize the value of the session variable somewhere, probably when you initialize the session. __________________
www.blake-foster.com |
|
#3
|
|||
|
|||
Re: Refresh page without changing anything in the pagethanks! works
|
|
#4
|
||||
|
||||
Re: Refresh page without changing anything in the pageYou're welcome.
__________________
www.blake-foster.com |
|
#5
|
||||
|
||||
Re: Refresh page without changing anything in the pageAnother solution is to use an intermediate script, as in the following example. The intermediate script is virtually invisible to the user, who can use Refresh and Back buttons without consequence.
form.php HTML Code:
validate.php PHP Code:
confirm.php PHP Code:
current_time.txt Code:
|
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Misunderstanding curses refresh()? | Catus | C++ Forum | 9 | 17-Jun-2008 05:50 |
| How to add a web page I created to apache | padan66 | Apache Web Server Forum | 2 | 21-Feb-2008 19:40 |
| Loading a php page in an iframe from javascript | Clive73 | Web Design Forum | 0 | 18-May-2005 07:10 |
| Javascript: Pop Up Tutorial | BobbyDouglas | Web Design Forum | 0 | 20-Nov-2003 23:19 |
| Search Engine Positioning 101 and 201 "How To" Tips... | 000 | Search Engine Optimization Forum | 0 | 29-May-2003 11:34 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The