Jump to content

Simple TXT search


Twango

Recommended Posts

Pretty simple thing:here's my code;

Enter website name in this format: www.site.tld (TLDs are .com, .net, .co etc):<br/><form method="post" action="index.php"><input type="text" name="ur"/><input type="submit" value="Check"/></form><?php$c = $_POST['ur'];$bado = fopen("bad.txt","r");$bad = $bado;fclose($bado);$goodo = fopen("good.txt","r");$good = $goodo;fclose($goodo);$neuo = fopen("neu.txt","r");$neu = $neuo;fclose($neuo);//Checksif ($c){if (substr_count($bad, $c) > 0){$stat = "Bad";}elseif (substr_count($good, $c) > 0){$stat = "Good";}elseif (substr_count($neu, $c) > 0){$stat = "Neutral";}else{$stat = "Not in our database";}if ($stat == "Bad"){echo "<h2><font color=red>The website $c has a bad record</font></h2>";}elseif ($stat == "Good"){echo "<h2><font color=lime>The website $c has a good record</font></h2>";}elseif ($stat == "Neutral"){echo "<h2><font color=yellow>The website $c has a neutral</font></h2>";}else{echo "<h2><font color=blue>The website $c has no records</font></h2>";}}?>

So, why is it always giving the no record thing?

Link to comment
Share on other sites

When you're reading from a file, you can either use fopen, fread, and fclose, or you can use file_get_contents. You're missing fread, you just open the file and close it again without reading from it.http://www.php.net/manual/en/function.fread.phphttp://www.php.net/manual/en/function.file-get-contents.phpYou can also use the file function to read a file and store the lines in an array:http://www.php.net/manual/en/function.file.phpIf each URL is on its own line, you can use file to read the lines into an array, and then use in_array to check if the string you're looking for is in the array.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...