Forum Moderators: coopster

Message Too Old, No Replies

browser address shows referrer page when I use header()

php issues with using header()

         

Bobus

4:19 am on Jan 22, 2008 (gmt 0)

10+ Year Member



Greetings, I'm having an issue using header() to redirect the browser after an update php page.

I use an edit page, edit.php, submit sends the page to an action page, action.php. The action page uses a header redirect to send the browser back to a menu page. The problem is that the url in the browser address window lists the action.php page. When you user refreshes the page it executes the action.php page again which causes duplicate records to be added to the database. My question: Is there any way to make header() show the real address and not the refferer page in the url.

Here is my code from the action.php page with the header:
$header="location: menu.php";
header ($header);

phranque

5:22 am on Jan 22, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would try an absolute url:
$header="Location: http://www.example.com/menu.php";
header ($header);

coopster

3:20 pm on Jan 22, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Bobus.

I always use an absolute URI too, good practice. The header [php.net] manual page has a note on this and a brief example of how you can build the absolute URI.

It's odd that your action.php page is showing in the address bar though ... are you using mod_rewrite somewhere in the mix?

phranque

3:27 pm on Jan 22, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



right - welcome to WebmasterWorld [webmasterworld.com], Bobus!

the header syntax is very strict.
case, space, etc