SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,307
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    anyway to pass on a variable when redirecting by header( 'Location: http://... ?

    in a php file i've got:
    Code:
    header( 'Location: http://'.$host_without_slash.'/thefile' );
    exit;
    is there anyway to pass on a variable/string, in particular the REQUEST_URI of the file which is doing the redirecting, so that it's accessible from withing /thefile ? quite possibly not but just want to check.

    thanks.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    header( 'Location: http://'.$host_without_slash.'/thefile?variable1=value&variable2=value' );

  3. #3
    SitePoint Guru
    Join Date
    Feb 2008
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean like this:

    Code PHP:
    $url = "http://" . $host_without_slash . "/thefile?string=" . $_SERVER['REQUEST_URI'];
    header("Location: $url");

  4. #4
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,307
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by corbyboy View Post
    Do you mean like this:

    Code PHP:
    $url = "http://" . $host_without_slash . "/thefile?string=" . $_SERVER['REQUEST_URI'];
    header("Location: $url");
    i should have said not in the query string! sorry, i thought of a query string decided i'd prefer not to use a query string, and forgot to mention that. :/

    yup i will use a query string if there's no other way, but is there an invisible to the user way? generate a POST request by the headers() function possibly? is that possible?

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    session. or cookies if the redirect goes to the same domain.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



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
  •