Re-submit a form after reload page

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
marcopais
Forum Newbie
Posts: 3
Joined: Fri Mar 13, 2009 5:03 am

Re-submit a form after reload page

Post by marcopais »

Hi there.

I have a form in main.php to insert data on a MySQL page. After submit, form action is process.php which inserts data. In the end of this file, it redirects (header()) to main.php again.

I did this to avoid re-submiting data after reload browser, but it isn't working. If I reload browser, data is inserted again.

I could control this with some cookies, but shouldn't it work like this?

Thanks in advance,

Regards,

MP
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Re-submit a form after reload page

Post by susrisha »

you should probably look at the header function manual.

1. There should be no output on the browser before you redirect.
2. Please check the syntax in case you might have missed something..
I had trouble even with a space character
marcopais
Forum Newbie
Posts: 3
Joined: Fri Mar 13, 2009 5:03 am

Re: Re-submit a form after reload page

Post by marcopais »

Solved.

I was not using a submit button. Instead, I was using a normal button width a onclick event. With a submit button, the method I was using works.

Thanks anyway.
Post Reply