Jump to content

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


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.

silly code but works good luck.

 

fully tested.

<?php

ob_start();

$message="hi there i am redarrow<br>Your going to google in 2 secs";

echo $message;

if($message){

header('refresh: 2; url=http://www.google.com'); 
}
?>

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'];
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.