Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Ok, now this might sound really really silly, but I need a plain old vanilla redirect from one page to another, while preserving all GET/POST params. AFAIK using $_SERVER['PHP_SELF'] doesn't carry along the parameters. Oh, and the redirect URL shouldn't be shown in the address bar (but if possible params are shown).

    So for example: http://www.mysite.com/index.php?show=10&do=this displays the page located at http://www.othersite.com/index.php?show=10&do=this. But without any change in the address bar. (And links pointing to "index.php" in the target page should still go to the current page, right?)

    And in case anyone's wondering, this is because I need to do an invisible redirect from one index.php to another for a forum site. And this is a friend's site and he's not sure about htaccess (although a solution with that would be appreciated too).

    My thought was to use script that enumerates all GET and POST variables and pass them on via an include (and I'm not sure if that's even possible). But I've been known for over-elegant solutions when a simpler one works. Can someone help me here?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  2.  

  3. #2
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    Is there anything wrong with using session variables in this situation? Then you could forgo passing stuff on through the URL the second time.

  4. #3
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Hmmm? What do you mean with sessions?? I never thought of using sessions here.

    Ok truth be told my friend needs to display contents from a free forum provider on his own page. He doesn't want the URL to point to the free provider but he wants the page to be displayed on his own site. Of course in-site functionality like the showthread GET params have to stay...
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Assuming you have PHP at your disposal, you can use http_build_query to build a querystring and redirect with the relevant GET parameters. The POST parameters will be substantially more difficult, as a redirect goes *to* the browser, which then goes to the relevant page. So the browser would have to read the parameters and then send them back, which it doesn't do.

    Basically, HTTP redirects will only carry GET parameters, as far as I know. You could rig a Javascript-based redirect on a page to achieve it (with a form submitting or what have you), but I don't think there's another way.

  6. #5
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Hmm, on that case, is there a solution with .htaccess?

    Thanks for the help!
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Is it a different page on the same domain? I somehow doubt even .htaccess would be able to help you here, but there's the off chance. The problem is, any move off of your domain has to go back to the browser first, and POST variables generally don't persist over a browser round-trip (and shouldn't do so, either).


Remove Ads

Posting Permissions

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

Search tags for this page

html redirecting with post params

Click on a term to search for related topics.
All times are GMT -6. The time now is 11:45 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com