php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #24070 Use post instead of get for header("Location:")
Submitted: 2003-06-06 16:59 UTC Modified: 2013-10-28 08:08 UTC
Votes:18
Avg. Score:4.9 ± 0.5
Reproduced:16 of 16 (100.0%)
Same Version:16 (100.0%)
Same OS:16 (100.0%)
From: john dot winstanley at angelsolutions dot co dot uk Assigned: krakjoe (profile)
Status: Closed Package: *General Issues
PHP Version: 4.3.2 OS: Any
Private report: No CVE-ID: None
 [2003-06-06 16:59 UTC] john dot winstanley at angelsolutions dot co dot uk
I'd like to be able to process a client request on one page and then pass that request along with information to another page using POST. 

At the moment all I can do is forward the request by using GET and the header("Location: someurl?attribute=4"); function.

Thanks Guys

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-06 18:34 UTC] sniper@php.net
There is the curl extension already which you should
use for that.

 
 [2003-06-13 09:47 UTC] john dot winstanley at angelsolutions dot co dot uk
Thanks for directing me to the curl extension it will be really helpfull but The advantage of PHP over all other scripting languages is its ease of use. 

This is the code needed to do a simple post request using curl.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"hello.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "postvar1=value1&postvar2=value2&postvar3=value3");
curl_exec ($ch);
curl_close ($ch); 

Too long too difficult to understand all the steps for the average user. We can make it easier as below but 
I'd like a function in the php core like this

postrequest($url,$parameters);

function postrequest($url,$parameters) {
 $ch = curl_init();

 curl_setopt($ch, CURLOPT_URL,$url)
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);

 curl_exec ($ch);
 curl_close ($ch); 
}

This would encourage PHP developers to use Java MVC like archutechture  where a request can be processed on one page and then forwarded to another with a requestDispatcher or  post request. Communication between different pages is currently one of PHPs big weaknesses where it loses out to servlets. Make curl part of the core and use simplfied functions to make it really easy to use!!
 [2013-10-28 08:08 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: krakjoe
 [2013-10-28 08:08 UTC] krakjoe@php.net
This is a misunderstanding of HTTP.

Closing the request.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 07:01:28 2024 UTC