note 6309 deleted from function.fsockopen by jimw

From: Date: Sat, 08 Dec 2001 21:55:48 +0000
Subject: note 6309 deleted from function.fsockopen by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22246@lists.php.net to get a copy of this message
For those interested, this is how I've used the post method. As far as I know, post is used for sending data to cgi scripts. For example, say you want to call a cgi-script that will add an entry to a guestbook: <PRE> // Data to pass to the cgi script $name = 'John Doe'; $email = 'johndoe@domain.com'; $msg = 'Nice site, I love your animated gif collection!'; // Build the request string $request = 'name=' . urlencode($name); $request .= '&email=' . urlencode($email); $request .= '&msg=' . urlencode($msg); // Build the header $header = "POST /guestbook/add.php3 HTTP/1.0\r\n"; $header .= "Content-type: application/x-www-form-urlencoded\r\n"; $header .= "Content-length: " . strlen($request) . "\r\n\r\n"; // Open the connection $fp = fsockopen('www.domain.com', 80, &$err_num, &$err_msg, 30); if ($fp) { // Send everything fputs($fp, $header . $request); // Get the response while (!feof($fp)) $response .= fgets($fp, 128); } </PRE> I think a browser would send something similar when submitting a form to a script.

« previous php.notes (#22246) next »