EchoFool Posted February 23, 2010 Share Posted February 23, 2010 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 ) ? Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/ Share on other sites More sharing options...
Deoctor Posted February 23, 2010 Share Posted February 23, 2010 I dont think this is at all possible..with php.. Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016576 Share on other sites More sharing options...
$Three3 Posted February 23, 2010 Share Posted February 23, 2010 Yeah, I also was wondering if there was a way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016577 Share on other sites More sharing options...
aleX_hill Posted February 23, 2010 Share Posted February 23, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016582 Share on other sites More sharing options...
EchoFool Posted February 23, 2010 Author Share Posted February 23, 2010 Damn - thats a shame Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016586 Share on other sites More sharing options...
thewooleymammoth Posted February 23, 2010 Share Posted February 23, 2010 you might be able to with js if you put the page in a frame, ubt i dont know for sure Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016590 Share on other sites More sharing options...
trq Posted February 23, 2010 Share Posted February 23, 2010 You can bypass the form altogether and submit your required data with curl. Not sure if that's what your after though. Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016593 Share on other sites More sharing options...
EchoFool Posted February 23, 2010 Author Share Posted February 23, 2010 ohh that be good thorpe! How is that done? Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016595 Share on other sites More sharing options...
thewooleymammoth Posted February 23, 2010 Share Posted February 23, 2010 You have to have curl installed. CHeck with your server company http://php.net/manual/en/book.curl.php Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016596 Share on other sites More sharing options...
Deoctor Posted February 23, 2010 Share Posted February 23, 2010 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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1016598 Share on other sites More sharing options...
EchoFool Posted February 28, 2010 Author Share Posted February 28, 2010 Confused on what that actually does? Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1019488 Share on other sites More sharing options...
inversesoft123 Posted February 28, 2010 Share Posted February 28, 2010 Simplest way allow your code to read sourcecode from remote webpage $file = file("http://site.com/form.php?$QUERY_STRING"); $file = @implode("", $file); echo $file; Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1019501 Share on other sites More sharing options...
jl5501 Posted February 28, 2010 Share Posted February 28, 2010 Yes, with cURL you can retrieve the form, fill it in, then post it back to the form's submit page. This will not work if the form contains a captcha image or other form of auto submit blocking Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1019505 Share on other sites More sharing options...
Deoctor Posted March 1, 2010 Share Posted March 1, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/193033-fill-in-a-form-on-external-website/#findComment-1019709 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.