Re: [PHP] HTML Post
I used a similar script and had the same problem I'm having with yours. The first few lines returned in the '$response' variable are the headers from the POST operation. When I get to the 'print' command at the end I get the headers generated by my server, then the headers retrieved from the POST operation are displayed on the page. Is this because of how I have my server configured? Or is there some run-tim way to tell the server to *not* generate headers, but simply send the specified text (including the headers) to the browser? Drew Kime -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML Post
On return, just cut out the part you don't need; PHP's string functions take care of this nicely - Original Message - From: Drew Kime [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, October 30, 2002 12:22 PM Subject: Re: [PHP] HTML Post I used a similar script and had the same problem I'm having with yours. The first few lines returned in the '$response' variable are the headers from the POST operation. When I get to the 'print' command at the end I get the headers generated by my server, then the headers retrieved from the POST operation are displayed on the page. Is this because of how I have my server configured? Or is there some run-tim way to tell the server to *not* generate headers, but simply send the specified text (including the headers) to the browser? Drew Kime -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HTML Post
How do you do a HTML post in php? Thanks -- Wei Weng Network Software Engineer KenCast Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML Post
Open a socket connection, formulate your data, post it to the host. Or do a searchfor the PostToHost() function. Good luck. -Kevin - Original Message - From: Wei Weng [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, October 29, 2002 3:44 PM Subject: [PHP] HTML Post How do you do a HTML post in php? Thanks -- Wei Weng Network Software Engineer KenCast Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML Post
? // Sends GET or POST, with data, to URL // $form_url:full URI, http://www.isp.com/directory/directory // $form_method: GET or POST // $form_data: associative array of data for GET or POST // $ShowRequest: if set, return the request sent to server // Request text enclosed by request/request // Returns: string with data received from server function GetPost( $form_url, $form_method, $form_data, $ShowRequest=NULL ) { // Build the request data string $request_data = ; if( isset($form_data) ) foreach ($form_data as $name = $value) $request_data .= $name.'='.urlencode($value).; $request_data = substr($request_data,0,-1); // Build the request $url = parse_url($form_url); $form_method = strtoupper($form_method); $request = $form_method. ; switch ($form_method) { case 'GET': $request .= $url['path'].?.$request_data. HTTP/1.0\r\n. Host: .$url['host'].\r\n\r\n; break; case 'POST': $request .= $url['path']. HTTP/1.0\r\n. Host: .$url['host'].\r\n. Content-type: application/x-www-form-urlencoded\r\n. Content-length: .strlen($request_data).\r\n\r\n. $request_data; break; default: die(Invalid method: .$form_method); } // Open the connection $fp = fsockopen($url['host'], 80, $err_num, $err_msg, 30); if ($fp) { if( isset($ShowRequest) ) $response = request$request/request\n; // Submit form fputs($fp, $request); // Get the response while (!feof($fp)) $response .= fgets($fp, 1024); fclose($fp); return $response; } else { echo 'Could not connect to: '.htmlentities($url['host']).'br /'; echo 'Error #'.$err_num.': '.$err_msg; exit; } } //EXAMPLE $mydata['q'] = 'php'; $mydata['start'] = '10'; $qq = GetPost(http://www.google.com/search,GET,$mydata); print $qq; ? - Original Message - From: Wei Weng [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, October 29, 2002 4:44 PM Subject: [PHP] HTML Post How do you do a HTML post in php? Thanks -- Wei Weng Network Software Engineer KenCast Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php