RE: [PHP] help please help

From: Date: Tue, 15 Apr 2003 19:32:01 +0000
Subject: RE: [PHP] help please help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144008@lists.php.net to get a copy of this message
When doing something like that I have had sucess with having the main action be PHP and then having the PHP script send data to the CGI either by socket or by cURL, depending on the application. <?php // //do a bunch of php processing up here // //now do the cgi stuff one of two ways //some vars so I don't have to type as much in the examples $request = "arg1=$val1&arg2=$val2"; $domain = "domainofcgifile.com"; $cgifile ="somefile.cgi"; //WITH A SOCKET -- the server doesn't have cURL, but sockets are on $fp = fsockopen($domain,80, $errno, $errstr, 30); if (!$fp) { //echo "no socket for me $errstr ($errno)<br>\n"; exit; } else { fputs ($fp, "POST $cgifile?$request HTTP/1.0\r\nHost: $domain\r\n\r\n"); while (!feof($fp)) { $return .= fgets ($fp,1280); } fclose ($fp); } //WITH CURL -- this one is on a secure server so I needed cURL $ch = curl_init() or die("Init failed"); curl_setopt($ch, CURLOPT_URL, "https://$domain/$cgifile"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_NOPROGRESS,0); curl_setopt($ch, CURLOPT_FAILONERROR, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result=curl_exec ($ch); curl_close ($ch); > -----Original Message----- > From: Didier McGillis [mailto:codesmoker@hotmail.com] > Sent: Tuesday, April 15, 2003 11:19 AM > To: php-general@lists.php.net > Subject: [PHP] help please help > > > > I'm sumbitting a form. Part of it has to go to a cgi form and > the other has > to execute some php. This is one form, so I need it to do it > once without > having somebody have to hit the button twice. > > anyone have a way of doing this. > > thanks, > > dan >

« previous php.general (#144008) next »