Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6345 > unrolled thread
| Started by | Robert Rosenberg <hal9001@panix.com> |
|---|---|
| First post | 2012-06-16 14:25 -0400 |
| Last post | 2012-06-18 09:54 +0200 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.lang.php
Simulating a Form Method=Post submission in PHP Robert Rosenberg <hal9001@panix.com> - 2012-06-16 14:25 -0400
Re: Simulating a Form Method=Post submission in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-06-16 14:45 -0400
Re: Simulating a Form Method=Post submission in PHP Luuk <luuk@invalid.lan> - 2012-06-16 20:46 +0200
Re: Simulating a Form Method=Post submission in PHP Robert Rosenberg <hal9001@panix.com> - 2012-06-16 20:10 -0400
Re: Simulating a Form Method=Post submission in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-06-16 20:41 -0400
Re: Simulating a Form Method=Post submission in PHP Luuk <luuk@invalid.lan> - 2012-06-17 20:14 +0200
Re: Simulating a Form Method=Post submission in PHP "J.O. Aho" <user@example.net> - 2012-06-17 14:19 +0200
Re: Simulating a Form Method=Post submission in PHP Denis McMahon <denismfmcmahon@gmail.com> - 2012-07-03 12:11 +0000
Re: Simulating a Form Method=Post submission in PHP Arno Welzel <usenet@arnowelzel.de> - 2012-06-18 09:54 +0200
| From | Robert Rosenberg <hal9001@panix.com> |
|---|---|
| Date | 2012-06-16 14:25 -0400 |
| Subject | Simulating a Form Method=Post submission in PHP |
| Message-ID | <CC0247F5.270E7%hal9001@panix.com> |
I would like to go to an external site and send a form to it via Post (simulating having generated the form and having the user submit it). I know that if I had been using GET, I could just code the parms along with the URL in the location command. To simulate Post I assume that I just need to use header to send the POST parms but I do not know the format of what to place in the header request (and I assume that I then use location to fire off to connection). Can someone either supply me with a sample code to do this or give me the URL of the documentation of the Headers that get sent by Post so I can look them up and create the needed script myself. Thank You.
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-06-16 14:45 -0400 |
| Message-ID | <jrik8h$ovm$2@dont-email.me> |
| In reply to | #6345 |
On 6/16/2012 2:25 PM, Robert Rosenberg wrote: > I would like to go to an external site and send a form to it via Post > (simulating having generated the form and having the user submit it). I know > that if I had been using GET, I could just code the parms along with the URL > in the location command. To simulate Post I assume that I just need to use > header to send the POST parms but I do not know the format of what to place > in the header request (and I assume that I then use location to fire off to > connection). > > Can someone either supply me with a sample code to do this or give me the > URL of the documentation of the Headers that get sent by Post so I can look > them up and create the needed script myself. > > Thank You. > Look up the cURL functions. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-06-16 20:46 +0200 |
| Message-ID | <6s0va9-ugd.ln1@luuk.invalid.lan> |
| In reply to | #6345 |
On 16-06-2012 20:25, Robert Rosenberg wrote: > I would like to go to an external site and send a form to it via Post > (simulating having generated the form and having the user submit it). I know > that if I had been using GET, I could just code the parms along with the URL > in the location command. To simulate Post I assume that I just need to use > header to send the POST parms but I do not know the format of what to place > in the header request (and I assume that I then use location to fire off to > connection). > > Can someone either supply me with a sample code to do this or give me the > URL of the documentation of the Headers that get sent by Post so I can look > them up and create the needed script myself. > > Thank You. > use curl (example #2) see: http://www.php.net/manual/en/function.curl-setopt.php or file_get_contents see: http://www.php.net/manual/en/function.file-get-contents.php#108309
[toc] | [prev] | [next] | [standalone]
| From | Robert Rosenberg <hal9001@panix.com> |
|---|---|
| Date | 2012-06-16 20:10 -0400 |
| Message-ID | <CC0298A1.2712F%hal9001@panix.com> |
| In reply to | #6348 |
On 06/16/2012 14:46, in article 6s0va9-ugd.ln1@luuk.invalid.lan, "Luuk" <luuk@invalid.lan> wrote: > On 16-06-2012 20:25, Robert Rosenberg wrote: >> I would like to go to an external site and send a form to it via Post >> (simulating having generated the form and having the user submit it). I know >> that if I had been using GET, I could just code the parms along with the URL >> in the location command. To simulate Post I assume that I just need to use >> header to send the POST parms but I do not know the format of what to place >> in the header request (and I assume that I then use location to fire off to >> connection). >> >> Can someone either supply me with a sample code to do this or give me the >> URL of the documentation of the Headers that get sent by Post so I can look >> them up and create the needed script myself. >> >> Thank You. >> > > > use curl (example #2) > see: http://www.php.net/manual/en/function.curl-setopt.php > > or file_get_contents > see: http://www.php.net/manual/en/function.file-get-contents.php#108309 > Thank You. Example 2 was EXACTLY what I needed (even though all I wanted to do was pass a set of parms not load a file). One other query. I seem to remember a site whose function was to display all the headers being passed. I think it was a security type page whose purposed was to show all the data being leaked/sent in the headers when you connect. I would like to see what I ended up sending (as well as all the headers being sent) so I have a reference to see what the cURL function caused the browser to send. Cam you refresh my memory by supplying a URL for that site. Thank You.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-06-16 20:41 -0400 |
| Message-ID | <jrj94r$leo$1@dont-email.me> |
| In reply to | #6350 |
On 6/16/2012 8:10 PM, Robert Rosenberg wrote: > On 06/16/2012 14:46, in article 6s0va9-ugd.ln1@luuk.invalid.lan, "Luuk" > <luuk@invalid.lan> wrote: > >> On 16-06-2012 20:25, Robert Rosenberg wrote: >>> I would like to go to an external site and send a form to it via Post >>> (simulating having generated the form and having the user submit it). I know >>> that if I had been using GET, I could just code the parms along with the URL >>> in the location command. To simulate Post I assume that I just need to use >>> header to send the POST parms but I do not know the format of what to place >>> in the header request (and I assume that I then use location to fire off to >>> connection). >>> >>> Can someone either supply me with a sample code to do this or give me the >>> URL of the documentation of the Headers that get sent by Post so I can look >>> them up and create the needed script myself. >>> >>> Thank You. >>> >> >> >> use curl (example #2) >> see: http://www.php.net/manual/en/function.curl-setopt.php >> >> or file_get_contents >> see: http://www.php.net/manual/en/function.file-get-contents.php#108309 >> > > Thank You. > > Example 2 was EXACTLY what I needed (even though all I wanted to do was pass > a set of parms not load a file). > > One other query. I seem to remember a site whose function was to display all > the headers being passed. I think it was a security type page whose purposed > was to show all the data being leaked/sent in the headers when you connect. > I would like to see what I ended up sending (as well as all the headers > being sent) so I have a reference to see what the cURL function caused the > browser to send. Cam you refresh my memory by supplying a URL for that site. > > Thank You. > You may be thinking of the HTTP Headers plugin for Firefox. A great tool, but it doesn't help with cURL because cURL doesn't use the browser. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-06-17 20:14 +0200 |
| Message-ID | <9dj1b9-7gs.ln1@luuk.invalid.lan> |
| In reply to | #6351 |
On 17-06-2012 02:41, Jerry Stuckle wrote: > On 6/16/2012 8:10 PM, Robert Rosenberg wrote: >> I would like to see what I ended up sending (as well as all the headers >> being sent) so I have a reference to see what the cURL function caused >> the >> browser to send. Cam you refresh my memory by supplying a URL for that >> site. >> >> Thank You. >> > > You may be thinking of the HTTP Headers plugin for Firefox. A great > tool, but it doesn't help with cURL because cURL doesn't use the browser. > or, if you use IE, press F12.... ;)
[toc] | [prev] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2012-06-17 14:19 +0200 |
| Message-ID | <a460bgFcb0U1@mid.individual.net> |
| In reply to | #6350 |
Robert Rosenberg wrote:
> On 06/16/2012 14:46, in article 6s0va9-ugd.ln1@luuk.invalid.lan, "Luuk"
>> use curl (example #2)
>> see: http://www.php.net/manual/en/function.curl-setopt.php
> Example 2 was EXACTLY what I needed (even though all I wanted to do was pass
> a set of parms not load a file).
>
> One other query. I seem to remember a site whose function was to display all
> the headers being passed. I think it was a security type page whose purposed
> was to show all the data being leaked/sent in the headers when you connect.
> I would like to see what I ended up sending (as well as all the headers
> being sent) so I have a reference to see what the cURL function caused the
> browser to send. Cam you refresh my memory by supplying a URL for that site.
First of all, when you are using PHP on a website, everything regarding PHP is
executed on the web server, so the users web browser will not do anything more
than send a form to your script.
If you want to have header information which curl sent to the server, you can
do the following before you use curl_close():
$sentheader = curl_getinfo($ch, CURLINFO_HEADER_OUT);
If you want to have the header you got from the remote server, then do the
following before curl_exec():
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
and before curl_close():
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
If you are interested of seeing the header that the user sent when they posted
the the form:
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
This will only work on a apache server, depending on how you have setup the
apache server to execute php. There is suggestion on a work around which you
can read at:
http://www.rvaidya.com/blog/php/2009/02/25/get-request-headers-sent-by-client-in-php/
--
//Aho
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-07-03 12:11 +0000 |
| Message-ID | <jsunhe$ibt$1@dont-email.me> |
| In reply to | #6350 |
On Sat, 16 Jun 2012 20:10:09 -0400, Robert Rosenberg wrote: > One other query. I seem to remember a site whose function was to display > all the headers being passed. Assuming you have a web server available to you, it shouldn't be too difficult to set this up yourself. Just make a page on your server that logs the relevant data to a file, and point your curl routines at that page. Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2012-06-18 09:54 +0200 |
| Message-ID | <4FDEDE99.2060903@arnowelzel.de> |
| In reply to | #6345 |
Robert Rosenberg, 16.06.2012 20:25: > I would like to go to an external site and send a form to it via Post > (simulating having generated the form and having the user submit it). I know > that if I had been using GET, I could just code the parms along with the URL > in the location command. To simulate Post I assume that I just need to use > header to send the POST parms but I do not know the format of what to place > in the header request (and I assume that I then use location to fire off to > connection). If available - use curl: <http://php.net/manual/en/book.curl.php> > Can someone either supply me with a sample code to do this or give me the > URL of the documentation of the Headers that get sent by Post so I can look > them up and create the needed script myself. <?php $data = array( 'field1'=>'value1', 'field2'=>'value2' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://server.example'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_exec($ch); curl_close($ch); ?> -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web