Re: [PHP] How to send "post"-variables in a "Location" header
[email protected] (Daniel Brown)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CAD9cneO9DUAmnEA=i6me3wcBqT8NbLBS5HKM6+JWrikE4YB95Q@mail.gmail.com> |
On Mon, Aug 26, 2013 at 3:48 PM, Ajay Garg <[email protected]> wrote: > Hi all. > > I have a scenario, wherein I need to do something like this :: > > ############################################################### > $original_url = "/autologin.php"; > $username = "ajay"; > $password = "garg"; > > header('Location: ' . $original_url); > ############################################################### > > As can be seen, I wish to redirect to the URL "autologin.php". > > Additionally, I wish to pass two POST key-value pairs :: "user=ajay" and > "password=garg" (I understand that passing GET key-value pairs is trivial). > > Is it even possible? > If yes, I will be grateful if someone could let me know how to redirect to > a URL, passing the POST key-value pairs as necessary. No. Sending a 'Location:' header issues an HTTP 301 by default, which means the browser will follow it using a GET request. If you can't pass the information from one location to another using sessions or (less ideally) cookies, you might consider doing a cURL POST request in the background and passing the session ID back to the browser, and having it handle it appropriately (read: session hijack). -- </Daniel P. Brown> Network Infrastructure Manager http://www.php.net/