• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP: Direct to another HTML page?

Appledrop

Platinum Member
heh, all in titles really, ive attached the php code (i think?).
when the user presses submit on my first html page, and it runs the php script, i want it to display a different HTML file..

thanks
 
Why not just post to another page in your form?

<form action="newpage.php" method="post">
<input...
</form>
 
Header("Location: otherPage.php");

I use that because I like to keep validation/processing pages separate from entry/navigation pages.
 
Originally posted by: mugs
Header("Location: otherPage.php");

I use that because I like to keep validation/processing pages separate from entry/navigation pages.

Actually, PHP buffers it's output and headers, so by simply calling header('Location: myloc.php'); your script could execute unexpected code.

so, do this:

header("Location: otherpage.php");
exit;

Also, according to HTTP/1.1 standards, when you send a Location header, you're supposed to send a full, absolute URL (including the HTTP), so in reality you'd want to do something like:

header("Location: http://myserver.com/myscript.php");
exit;

I actually use a function that determines what kinds of url you're trying to redirect to (local absolute, local relative, or remote) and formats an absolute URI, then redirects to it. I've attached to code snippet so you can see/use it. It can also handle querystrings on the end of the addresses, and encodes them correctly.

Usage:

// Local Relative
Redirect('../myurl.php');
or
Redirect('myurl.php');

// Local Absolute
Redirect('/myurl.php');

// Remote
Redirect("http://www.myurl.com/")
 
Originally posted by: Beau
Originally posted by: mugs
Header("Location: otherPage.php");

I use that because I like to keep validation/processing pages separate from entry/navigation pages.

Actually, PHP buffers it's output and headers, so by simply calling header('Location: myloc.php'); your script could execute unexpected code.

so, do this:

header("Location: otherpage.php");
exit;

I prefer not to have exit points scattered throughout a page, so I usually put the redirect at the end of the page and use conditionals if I want to prevent some code from executing.
 
Back
Top