# \[PHP\] POSTing to another site

**URL:** <https://forum.kirupa.com/t/php-posting-to-another-site/38642>\
**Category:** Uncategorized\
**Created:** [December 27, 2003, 12:21pm UTC](https://forum.kirupa.com/t/php-posting-to-another-site/38642 "2003-12-27T12:21:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![955](https://avatars.discourse-cdn.com/v4/letter/9/4bbf92/32.png) [@955](https://forum.kirupa.com/u/955)\
**Post date:** [December 27, 2003, 12:21pm UTC](https://forum.kirupa.com/t/php-posting-to-another-site/38642/1 "2003-12-27T12:21:22Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2003, 2:58pm UTC](https://forum.kirupa.com/t/php-posting-to-another-site/38642/2 "2003-12-27T14:58:20Z")

</div>

this works for the validator:

[http://validator.w3.org/check?uri=http%3A%2F%2Fwww.reqkills.com&charset=(detect+automatically)&doctype=(detect+automatically)&ss=1](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/](http://validator.w3.org/)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2003, 3:03pm UTC](https://forum.kirupa.com/t/php-posting-to-another-site/38642/3 "2003-12-27T15:03:07Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2003, 3:08pm UTC](https://forum.kirupa.com/t/php-posting-to-another-site/38642/4 "2003-12-27T15:08:06Z")

</div>

I don’t think there is a way of sending post variables to another site like that for security reasons… :sigh:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 28, 2003, 12:05am UTC](https://forum.kirupa.com/t/php-posting-to-another-site/38642/5 "2003-12-28T00:05:40Z")

</div>

Aha! the cURL library looks like just what the doctor ordered.

[http://uk2.php.net/manual/en/ref.curl.php](http://uk2.php.net/manual/en/ref.curl.php)

Now all I gotta do is figure out how to do it 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 28, 2003, 10:52pm UTC](https://forum.kirupa.com/t/php-posting-to-another-site/38642/6 "2003-12-28T22:52:32Z")

</div>

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

<?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](http://www.skehin.com/php_curl.php)
