cancel
Showing results for 
Search instead for 
Did you mean: 

POST and GET problems

NeilB
Newbie
Posts: 7
Registered: 06-08-2007

POST and GET problems

Hiya

Trying to POST or GET to one of my own php routines on the Force9 cgi server (using the path as you would type it into internet explorer).

Tried two methods now - both to no sucess (long time taken then script seems to give up on call).

Both methods work when I call a routine at itagg.com but neither work when calling my own routine, or make a log entry on a friends unix server when I point them to that.

Its really important that I get this working but I'm completely out of ideas. Any suggestions?

Thanks in advance,

Neil
6 REPLIES
N/A

POST and GET problems

Are you aware that PHP scripts must be placed ouside the cgi-bin directory? If it's inside cgi-bin (or a sub-directory within cgi-bin) it will not work.

If that's not the answer, can you show us your HTML (probably best to post a link) so people may see what it is you're trying to do.
NeilB
Newbie
Posts: 7
Registered: 06-08-2007

POST and GET problems

Hiya

Nope, its not in the cgi-bin. Its in the folder above this with other php scripts that are working fine. Had to check though!

I have stripped out the code to the basics so can post below. As I say, this code works fine if I point it to the itagg server. The script I am calling simply sends a text message using some default values (ie a simple test script to prove the script is being called).

The delay I get when executing the code below suggests to me that it cannot find my script, it also has a delay wwhen I point it to a friends server and no log entry is produced at his end.

Oh, below is example using "GET" - same result using "POST".

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
<?php
function httpSimulateFormSubmit($host, $method, $path, $data) {
$fp = @fsockopen($host, 80);
if ($fp) {
if ($method == 'GET') $path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') fputs($fp, $data);
while (!feof($fp)) $buf .= fgets($fp, 1024);
fclose($fp);
return $buf;
}
else return false;
}

function sendMessage($message) {
$correctedmessage = str_replace(" ", "+", $message);
$data = 'source=44&message=' . $message;
$error = httpSimulateFormSubmit('cgi.merigem.force9.co.uk', 'GET', '/testcall.php',$data);
}

$message='Hi+mum';
sendMessage($message);
?>
Routine has run.
</body>
</html>
N/A

POST and GET problems

Firstly, I believe "Host: whatever.domain.ext" is only used in HTTP/1.1 requests.
Secondly, I don't think your code would work on the F9 CGI Platform - as the CGI Servers can't connect back to themselves.
NeilB
Newbie
Posts: 7
Registered: 06-08-2007

POST and GET problems

Ok, I'll look into the "host:" bit - any code snippets for a current version?

Thanks a lot for the info about connecting back - going to integrate everything into one script now.

I assume that this has been done to stop recursion?

Is there a list of things that the Force9 CGI is limited from doing so I don't spend hours chasing my tail again?

Thank you again for your help - much appreciated.

Neil
N/A

POST and GET problems

I would just replace 1.0 with 1.1 Smiley

Regarding the list, Not as far as I know, unfortunately.
NeilB
Newbie
Posts: 7
Registered: 06-08-2007

POST and GET problems

Hehe - ok - 1.0 replaced with 1.1!!

Routines rejiggled to avoid calling the F9 server and all happily working now. Hoorah!!

Thanks again for your help Cheesy