On Fri, 17 Oct 2003 08:54:23 +0200 (MEST), you wrote: >I have a php file in website A's directory, which, when given a key value, >will check whether it is valid or not. Is there any way I can treat this >website like a function and have it give me a return value after it has "run >through" ?
Yes; some kind of Remote Procedure Call protocol (eg SOAP) is designed for this. But the lightweight way would be something like: function get_token_validity ($token) { $token = 'token=' . rawurlencode ($token); // armour message for sending $host = 'www.webserverA.com'; if (($sp = fsockopen ($host, 80)) == FALSE) { return (NULL); } fputs ($sp, "POST /path/to/script.php HTTP/1.0\r\n"); fputs ($sp, "Host: $host\r\n"); fputs ($sp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs ($sp, "Content-length: " . strlen ($token) . "\r\n\r\n"); fputs ($sp, "$token\r\n"); $result = NULL; while (!feof ($sp)) { $a = fgets ($sp); if (is_numeric ($a)) { if ($a == FALSE) { $result = FALSE; } else { $result = TRUE; } } } fclose ($sp); return ($result); } Untested, but it should be pretty close. Returns TRUE on a valid result, FALSE on invalid and NULL on error. The paired script on www.webserverA.com should just echo(1) or echo(0) for a good or bad result. >By the way, I work with php3, so I hope there's a solution for that version >;) /Ah/. I have to ask... why? I have no idea whether the above code will run on PHP 3. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php