Log in

View Full Version : index.php?=new url



bojomojo
12-07-2008, 01:59 PM
I need my index.php?=new url redirects me to the new url, how can this be done

hmsnacker123
12-08-2008, 04:16 AM
<?php

$wheretogo = $_GET['url'];

header("Location: ".$wheretogo."");

?>


Example Usage: yourfile.php?url=http://www.google.com/

hmsnacker123
12-10-2008, 07:45 AM
Here's another way using a form that i written:



<?php
if(!$_POST['submit']){
echo "<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">\n";
echo "<input type=\"text\" value=\"http://\" name=\"url\" /> Redirect Type: <select name=\"type\">\n";
echo "<option value=\"1\">Header</option>\n";
echo "<option value=\"2\">Meta</option>\n";
echo "<option value=\"3\">JavaScript</option>\n";
echo "</select>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Go &raquo;\" />\n";
echo "</form>\n";
}else {
$url = $_POST['url'];
$type = $_POST['type'];
if(!$url){
echo("Please supply a url.");
}else {
switch($type){
case 3:
echo "<script type=\"text/javascript\">";
echo "window.onload = function(){";
echo "document.location = '".$url."';";
echo "}";
echo "</script>";
break;
case 2:
echo "<meta http-equiv=\"refresh\" content=\"0;url=".$url."\" />";
break;
case 1:
header("Location: ".$url."");
break;
default:
header("Location: ".$url."");
break;
}
}
}
?>