View Full Version : [PHP] POSTing to another site.
λ
December 27th, 2003, 08:21 AM
I'm writing a blog, and I want to make sure that all my pages validate as XHTML. I want to let people post comments, but they might not post validating HTML.
So I thought I'd use the W3's XHTML validator(saves me a lot of work)
The problem with this is that the W3's XHTML validator accepts data via POST only, and not GET:trout:.
Does anyone know how I can send info to another page on a whole different server using POST, and then read the data sent back?
I know how to use fopen() to manipulate data for GET pages, it's just POST that is the problem.
Thanks :)
Jubba
December 27th, 2003, 10:58 AM
this works for the validator:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.reqkills.com&charset=%28detect+automatically%29&doctype=%28detect+automatically%29&ss=1
and that is get...
http://validator.w3.org/
λ
December 27th, 2003, 11:03 AM
that's not the validator I meant.. but actually, I might have come up with an alternative anyway..
I meant the WDG validator here: http://www.htmlhelp.com/tools/validator/direct.html
I suppose I could write a little snippet of code that would write the HTML to a unique file and then send that URL to the W3C validator.
I'd still be interested in knowing whether there is a way of doing this though.
Jubba
December 27th, 2003, 11:08 AM
I don't think there is a way of sending post variables to another site like that for security reasons... :sigh:
λ
December 27th, 2003, 08:05 PM
Aha! the cURL library looks like just what the doctor ordered.
http://uk2.php.net/manual/en/ref.curl.php
Now all I gotta do is figure out how to do it :P
λ
December 28th, 2003, 06:52 PM
Well, I got it working.
In case anyone wants to know how, I used cURL from the command line. My host must have got it installed or something(they didn't have the library).
Here's the code I used:
<?php
$html = urlencode(
'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>test</title></head>
<body><p>This is a test of the XHTML validator</p></body>
</html>
');
$var = shell_exec("curl -d \"area=$html&charset=UTF-8&warnings=yes&input=yes\" http://www.htmlhelp.com/cgi-bin/validate.cgi");
print $var;
?>
with the output: www.skehin.com/php_curl.php
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.