Jump to content

[SOLVED] How can I use php to redirect to a different page?


bobleny

Recommended Posts

Is there a different way of doing this, a way to redirect the page using PHP after text has been entered into the browser?

 

Why would you need to output anything if all your going to do is redirect to another page? Makes no sense. Alot of people get there logic wrong here.

echo "text
<META HTTP-EQUIV=REFRESH CONTENT="2;URL=http://www.mynewurl.com">";

It's not php, but it will work.

 

Thats what I have been using, but no matter how you do it, there is still a delay. The line has to be echoed, php has to stop, then, in your example, the user has to wait 2 seconds and thats only if their browser supports that tag...

 

 

Is there a way to do what I want to do in php?

i don't know if it's relevent or not but i was browsing php.net and found something about Output Control Functions that sounds like could help

 

http://www.php.net/manual/en/ref.outcontrol.php

 

i have no idea if this helps but just thought i'd throw it out there.

Thanks for this.  I used it to create a dynamic dropdown that redirects when a selection is made.

 

<?php
print "<font face=verdana size=2><br /><br />";
print "Redirect Me<br />";
$result = scandir(".");
echo "<form enctype=multipart/form-data name=pick method=get action=$val>";
echo "<select onChange=javascript:document.pick.submit() name='goscript'>";
foreach($result as $val) {
    $val = trim($val);
    echo "<option value='$val'>$val</option>\n";
}

if (isset($_GET['goscript'])) {
header('Location: http://www.example.com/' . $_GET['goscript']);
}

echo "</select></form>";
print "</font>";
print $_GET['goscript'];
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.