Results 1 to 3 of 3

Thread: index.php?=new url

  1. #1
    Join Date
    Nov 2008
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default index.php?=new url

    I need my index.php?=new url redirects me to the new url, how can this be done

  2. #2
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    PHP Code:
    <?php

    $wheretogo 
    $_GET['url'];

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

    ?>
    Example Usage: yourfile.php?url=http://www.google.com/
    Last edited by hmsnacker123; 12-10-2008 at 02:57 AM.

  3. #3
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    Here's another way using a form that i written:

    PHP Code:
    <?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;
                }    
            }    
        }
    ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •