Jump to content

Fill in a form on external website?


EchoFool

Recommended Posts

Hey

 

I have a page which generates a code that you can activate on a different website - but i was wondering if there was a way for PHP to fill the input box automatically for you when you click a link to the page which contained the input box ?

 

Say it was named

 

<input typt="text" value = "" name="code" >

 

And that was on a completely different server - and you want "12345" to be auto filled into that input box from your page how can this be achieved (if at all )  ?

 

 

Link to comment
Share on other sites

If I understand correctly, then No, there is no way for PHP to do this.

 

PHP is a server based language which parses a page as it is created.

 

What you are trying to do is more client based (ie get the code that this website has given me, and stick it into this other website i am accessing).

 

I doubt there would be a way in js either, but I am not a js expert.

Link to comment
Share on other sites

curl can do that ....

though there are some problems in that one..

check this code for example..

 

<?php
$userAgent = "IE 7 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)";
$target_url = "http://google.com";

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$html = curl_exec($ch);
if (!$html) {

    

echo "
cURL error number:" .curl_errno($ch);

    

echo "
cURL error:" . curl_error($ch);

    

exit;
}
else
{
    var_dump($html);
}
?>

Link to comment
Share on other sites

Confused on what that actually does?

 

the code which i gave will actually fetch the html code of the page and provide you with that, u can write this to a file as well to see the output code..

but i was actually displaying it out. :)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.