Kiwi Chris Posted August 18, 2009 Share Posted August 18, 2009 Hi, I really know very little about php. I am wanting to find a way check a specific number on a foreign website. Two websites are involved Site A (Mysite) and Site B (external Site) Site A - user gets a random code That user adds this random code to site B The user then comes back to Site A and clicks next Site A script goes to Site B and checks the page for that random code If that code has been added then open another page on Site A. ............... I have asked around but no one has been able to help me. I was suggested to use file_get_content to get the data and function rand() for the random code. ........................ From my understanding I would create a form that provides the user with the random code and a button they press after adding the code to site B. When the button is pressed file_get_content is used to check the code is there and if it is moves to next page of registration, and if fails an error message. ....................... I am not afraid of trying to make this code I really just have no idea where to go to get the information I need to do this. I would really appreciate any helpful information you may be able to assist me with. Kind Regards Kiwi Chris. Quote Link to comment https://forums.phpfreaks.com/topic/170814-check-webpage-for-specific-text/ Share on other sites More sharing options...
Catfish Posted August 18, 2009 Share Posted August 18, 2009 Start with http://www.php.net/doc look up those functions you talked about. You might also need to look up about $_POST variable for using values passed from user-submitted forms. Quote Link to comment https://forums.phpfreaks.com/topic/170814-check-webpage-for-specific-text/#findComment-900829 Share on other sites More sharing options...
Garethp Posted August 18, 2009 Share Posted August 18, 2009 http://devzone.zend.com/article/1081 Quote Link to comment https://forums.phpfreaks.com/topic/170814-check-webpage-for-specific-text/#findComment-900830 Share on other sites More sharing options...
Kiwi Chris Posted August 18, 2009 Author Share Posted August 18, 2009 Sadly I am still very lost after reading both of these sites. This is why I thought the only way was to ask here. with file_get_content i see theirs a way to get information from a URL, I see you can set this to the amount of data you want. I didn't see how you could look for a specific data in that page. With cURL I saw a script for looking for books on amazon I could not figure out how I would go about changing this to find a random code on a page. I realize it is important to search and to try to figure these things out on ones own and believe me I have tried I really do need a little direction. Quote Link to comment https://forums.phpfreaks.com/topic/170814-check-webpage-for-specific-text/#findComment-900863 Share on other sites More sharing options...
JonnoTheDev Posted August 18, 2009 Share Posted August 18, 2009 Here you go. In this example I am checking to see if www.mywebsite.com is found at http://www.abc.com <?php function checkRemoteValue($url, $value) { ob_start(); if(!@readfile($url)) { return false; } $body = ob_get_contents(); ob_end_clean(); if(stristr(htmlentities($body),$value)) { return true; } return false; } // usage if(checkRemoteValue("http://www.abc.com", "www.mywebsite.com")) { print "found"; } else { print "not found"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/170814-check-webpage-for-specific-text/#findComment-900870 Share on other sites More sharing options...
Kiwi Chris Posted August 18, 2009 Author Share Posted August 18, 2009 Thank you so much, I will work with that and let you know how I get on. I really appreciate you taking the time to assist me, very quick response from everyone I will be saving this site to my favorites. Quote Link to comment https://forums.phpfreaks.com/topic/170814-check-webpage-for-specific-text/#findComment-900871 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.