Problem with "Backing"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Problem with "Backing"

Post by harrisonad »

Hello

i am an intermediate user of php, yet some things still bug my codes since i first started:

when processing mysql query, i tend to separate the HTML form with the processing php page. then after executing the query(either adding new record or update it), i would redirect to another separate HTML page just for 'sucess message'.

the problem is, when the user "backs" (that is to click on the back button of a browser so as to retain previous page), the query executes again, resulting from "duplicate error" on mysql.

can anyone help me with this.

thanks in advance.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Do you use a header redirect to the success page (i.e. using [php_man]header()[/php_man])?

Mac
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

yes,

here it is:
header("location: message.html");

go on, tell me what's on you mind...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Just eliminating one potential problem with the header question :)

Think I know how to solve this: put the processing code into a separate file from the display code, then the submit button takes you to the processing page which redirects you to the success page. Pressing the back button from the success page takes you to the display page.

Mac
Post Reply