Discussion:
How to send "post"-variables in a "Location" header
Ajay Garg
2013-08-26 19:48:01 UTC
Permalink
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.


Looking forward to a reply :)
--
Regards,
Ajay
m***@behnke.biz
2013-08-26 20:02:21 UTC
Permalink
Post by Ajay Garg
Hi all.
###############################################################
         $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.
Iirc it is not possible to pass post body content via location redirect.
What you can do: Set auth headers

http://forums.phpfreaks.com/topic/84480-solved-how-to-send-authorization-basic-header/
Post by Ajay Garg
Looking forward to a reply :)
--
Regards,
Ajay
--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ***@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Matijn Woudt
2013-08-26 20:42:29 UTC
Permalink
Post by Ajay Garg
Hi all.
###############################################################
$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.
Looking forward to a reply :)
Usually you would pass this around in sessions. If you must however use
post, you can only do so with using some javascript magic. Write a form
with hidden input and auto submit it.

- Matijn
Tamara Temple
2013-08-26 20:48:13 UTC
Permalink
Post by Ajay Garg
Hi all.
###############################################################
$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.
Looking forward to a reply :)
Since this seems that it will not work, I'm wondering if you could take a step back for us and say what is it you're hoping to accomplish by this. Maybe there's a better way to get you what you need that is possible, and also will be good PHP. Describe your scenario in higher level terms, not how you'd implement it, but what the outcome you need is, and what the design goal is for the user.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Daniel Brown
2013-08-27 16:29:25 UTC
Permalink
Post by Ajay Garg
Hi all.
###############################################################
$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/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Continue reading on narkive:
Loading...