barryflood22 Posted June 26, 2011 Share Posted June 26, 2011 I have to develop something for a client, it involves a user inputting a url, the script checking the source code of the url, if a certain line of code exists it should display a predifined line of text such as "successfull" or "url doesnt not contain ____" anyone have any ideas? Link to comment https://forums.phpfreaks.com/topic/240477-php-help/ Share on other sites More sharing options...
.josh Posted June 26, 2011 Share Posted June 26, 2011 my idea is for you to stop taking on clients if you don't know how to do the work. Link to comment https://forums.phpfreaks.com/topic/240477-php-help/#findComment-1235160 Share on other sites More sharing options...
QuickOldCar Posted June 26, 2011 Share Posted June 26, 2011 Create a form for url input. Connect to url with Curl. Get raw html. Match content html with preg_match(). Echo results if content found or not. I take it you do not program with php but got sucked into this somehow? Link to comment https://forums.phpfreaks.com/topic/240477-php-help/#findComment-1235164 Share on other sites More sharing options...
ZulfadlyAshBurn Posted June 27, 2011 Share Posted June 27, 2011 This might help you. You will first need a form to in the main page. index.html <form method="post" action="check.php"> URL: <input type="text" value="" name="url"/></br> Text to find: <input type="text" value="" name="ttf"/> </form> check.php <?php // get data from form $url = $_POST["url"]; $ttf = $_POST["ttf"]; // check if page exist if (file_exists($url)) { // file open and read $fh = fopen($url, 'r'); // find text in file $pos = strpos($fh, $ttf); // check if text if found in source code is false if (pos === false) { // echo that the text cannot be found echo "Url doesnt not contain" . $ttf ; } // else echo that it is successful else { echo "Successful"; } } // if page cannot be found, echo fail else { echo "Url doesnt not contain" . $ttf ; } ?> if it works for you, you may want to donate to me for helping? you should earn quite a fair bit of amount for doing it for your client. Link to comment https://forums.phpfreaks.com/topic/240477-php-help/#findComment-1235254 Share on other sites More sharing options...
QuickOldCar Posted June 27, 2011 Share Posted June 27, 2011 <?php $url = $_POST['url']; $term = $_POST['term']; ?> <form method="post" action=""> URL: <input type="text" value="<?php echo $url;?>" name="url"/></br> Search Term: <input type="text" value="<?php echo $term;?>" name="term"/> <input type="submit" value="Search"/> </form> <?php if(isset($_POST['url']) && !empty($_POST['url']) && isset($_POST['term']) && !empty($_POST['term'])){ $content = file_get_contents($url); if (preg_match("/$term/i", $content)) { echo $term ." exists."; } else { echo $term . " not found."; } } else { echo "Insert value."; } ?> Link to comment https://forums.phpfreaks.com/topic/240477-php-help/#findComment-1235274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.