Click to See Complete Forum and Search --> : PHP as CGI???


tbirnseth
07-31-2007, 10:50 PM
I have the following php script I wanted to put in a CGI directory to see the results of what would be posted so I can detemine which of the values I subsequently want to post to somewhere else.

I have the permission of the file set to 755. I have installed it in the cgi-bin directory. I've tried executing it from php via the curl library passing both GET and POST parameters. But apache returns a missconfiguration error and the error log says "Premature end of script headers".

I'm not a perl person or I'd simply do the same in perl. But that won't help me when I put together the actual page that will do the translation of information and subsequent post back to my server.

So can someone tell me what I might be doing wrong or another way to skin this cat?

thanks,
tony
P.S. I've tried it with and without the ending .php (read that some interpeters require this).



!#/usr/local/bin/php
$sendMail = TRUE;
echo "Content-type: text/html\n\n";

$getParams = array();
$postParams = array();
$subject = 'Order get/post for ShopSite';
$to = 'xxx@example.com';
$from = 'xxx@comcast.net';
$cc = '';
$headers = "From: $from\r\n".($cc ? "Cc: $cc\r\n" : "");
$body = '';

$postParms = $_POST;
$getParams = $_GET;

$body .= "Get Parameters:\n";
foreach($getParams as $name => $value)
$body .= sprintf("\t%20s: %s\n", $name, $value);

$body .= "\n\nPost Parameters:\n";
foreach($postParams as $name => $value)
$body .= sprintf("\t%20s: %s\n", $name, $value);

if( $sendMail )
mail($to, $subject, $body, $headers);
exit;
.php

bluestars
08-19-2007, 11:55 AM
My interpreter requires you to enclose the text in php tags (<?php and ?>), although I don't know if that's the problem.