php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25693 No access to posted variables via socket connection
Submitted: 2003-09-29 12:11 UTC Modified: 2003-09-30 03:27 UTC
From: a dot erler at brain-at-work dot de Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.3.1 OS: Debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: a dot erler at brain-at-work dot de
New email:
PHP Version: OS:

 

 [2003-09-29 12:11 UTC] a dot erler at brain-at-work dot de
Description:
------------
I'm trying to send some variables via POST with a socket connection to a HTML form.
The problem: 
The socket connection returns HTML-code from the form, but in the form I can't access the variables I sent (e.g. "go" is not set in $HTTP_POST_VARS and not in the global scope).

I took the sample code from the PHP manual, section "Stream functions", "Example 2. Making a POST request to an https server".

I think it should be no problem, that there are additional GET-parameters in the URI "d_content_kontakt.php" !?

Reproduce code:
---------------
$sock = fsockopen("linux", 80, $errno, $errstr, 30);
$data = 'go='.urlencode('sent');
fputs($sock, "POST /caranet_redesign/d_content_kontakt.php?art_angebot=Gebrauchtwagen&id_haendler=00000002&id_lang=00000001&typ=rm&hersteller=&schlafplaetze=&preis_von=&preis_bis=&id_fahrzeuge=00002158 HTTP/1.0\r\n");
fputs($sock, "Host: linux\r\n");
fputs($sock, "Content-type: application/x-www-url-encoded\r\n");
fputs($sock, "Content-length: " . strlen($data) . "\r\n");
fputs($sock, "Accept: */*\r\n");
fputs($sock, "\r\n");
fputs($sock, "$data\r\n");
fputs($sock, "\r\n");

$headers = "";
while ($str = trim(fgets($sock, 4096)))
  $headers .= "$str\n";

print "\n";

$body = "";
while (!feof($sock))
  $body .= fgets($sock, 4096);

fclose($sock);



Expected result:
----------------
variable "go" should contain "sent", but is not set in d_content_kontakt.php


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-29 21:09 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

And your PHP version is too old..

 [2003-09-30 03:27 UTC] a dot erler at brain-at-work dot de
Sorry, Sniper, for stealing your time ;-)

But meanwhile I found the solution by myself:
I used the wrong content-type. Works much better with "application/x-www-form-urlencoded"...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 15:01:38 2025 UTC