mysterbx Posted February 9, 2008 Share Posted February 9, 2008 hi, Can curl get info from a page, and post it (postields) without reloading the page? Here is an example: $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url); curl_setopt($ch1, CURLOPT_FAILONERROR, 1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch1, CURLOPT_PORT, 80); curl_setopt($ch1, CURLOPT_TIMEOUT, 5); curl_setopt($ch1, CURLOPT_USERAGENT, $user_agent); $r1 = curl_exec($ch1); while ($r1) { preg_match("#\<input type=\"hidden\" name=\"ses\" value=\"([\d\w]+?)\"\>#ise", $r1, $one); preg_match("#\<input type=\"hidden\" name=\"time\" value=\"([\d\w\.]+?)\"\>#ise", $r1, $two); $params = "ses=".one[2]."&time=two[2]&name=curl"; } curl_setopt($ch1, CURLOPT_POST,1); curl_setopt($ch1, CURLOPT_POSTFIELDS,$params); curl_exec($ch1); page loads, curl gets info, and post's it without reloading the page (I dont know if I used the "while" function correctly) Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 9, 2008 Author Share Posted February 9, 2008 huh? Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 10, 2008 Author Share Posted February 10, 2008 please somebody! I know how to do this, but i dont know how to do it without refreshing the page.... Quote Link to comment Share on other sites More sharing options...
effigy Posted February 13, 2008 Share Posted February 13, 2008 AJAX? Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 13, 2008 Author Share Posted February 13, 2008 ajax? whats that? is it php? Quote Link to comment Share on other sites More sharing options...
KrisNz Posted February 13, 2008 Share Posted February 13, 2008 Yes, that's possible, no you haven't used while correctly. cURL returns all the page content at once so you don't need that loop at all. Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 14, 2008 Author Share Posted February 14, 2008 so how can I do this without refreshing the page... Curl does this: 1.goes to page, gets contents 2.goes to page (the new page loads) and post's data it should do this: 1. go to page, get contents, post em (no new page loading...) Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 16, 2008 Author Share Posted February 16, 2008 someone, please... Quote Link to comment Share on other sites More sharing options...
AnnieKay Posted February 17, 2008 Share Posted February 17, 2008 I'm fairly new to php so I'm not sure if there's a way to do it with php (although I don't think so and I don't see how). I think you should probably look into using AJAX - which would involve buying a book and learning it... AJAX is a scripting method that merges the DOM, standards based presentation and javascript - in effect, it ends up loading everything in the background so no refresh is needed and there is virtually no lag time (like when you move the map around in Google Maps). Good luck! Quote Link to comment 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.