Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

header() question

Status
Not open for further replies.

AtomicChip

Programmer
May 15, 2001
622
CA
Pages:

page1.php
page2.php

page1.php has a form (action=page2.php method=post).
page2.php executes some stuff and then calls header('page1.php');

The header() method works fine, but the url in the address bar is showing page2.php, not page1.php (as executed in the header() call).

How do I force the URL in the address bar to display the current pages' URL instead of the referring one?

Hope that makes sense...

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
I suspect that your header() invokation is not working find.

If you had used

header("Location: page1.php");

in your code and it worked correctly, the browser would have immediately disconnected from the current script and initiated a new connection to the script pointed to in the header. The URL of the browser will show the destination of the "Location" header.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
The redirection works fine...

Just not the address writing... Still not sure why...

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
i use this function sometimes. It allows me to embed the tag in the middle of the HTML code, rather than forcing me to do the redirection before the <head> tag:

Code:
function redirect($url,$str) {      //redirects the page to $url and displays $str for 1 second.
	if (isset($str)) { 
		echo $str; //something to display while redirecting
		sleep(1);
	} ?>
	<head><meta http-equiv="refresh" content="0;URL=<? echo $url; ?>"></head> <?
}

 
Huh, that's weird...

I'm developing on a Windows box, but my live server is Linux... Seems that the problem only occurs on the Windows (IIS) machine, but Apache handles it no problem.

Case closed.

Thanks :)

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
I'm not suprised. Mi[&cent;]ro$oft's software does some strange stuff with HTTP headers, both at the server and browser ends.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
You can run Apache within a windows environment. That may be a better course of action, unless you need IIS for something specific.

 
I'm primarily a C#/ASP.NET developer (hence, the need for IIS), working with PHP and admin'ing a *nix box for fun. As it's just a development box, I'm not too concerned with the way IIS handles headers. As long as it works on my server, that's pretty much all that matters to me =D

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top