I think i was doing halfway good to get this to halfway work. Anyways the following code works to find it on the first line, but i have a script that creates each on an individual line.
Please revise or create a completely new version of the following to make it to search for the form data on every line.
$search = $_POST['search'];
$file = file("SLIST.txt");
foreach($file as $line)
{
$line = trim($line);
if($line == $search)
{
echo $search . " WAS found in the database";
}
else
{
echo $search . " was NOT found in the database";
}
}
by form i mean there is a search form on the previous page. This page is the page where it tells you whether the text put into the search form matches a line in the file (ex: Line 1: BOOT Line 2: Tree Search entry: Tree Echo msg: Tree WAS found in the database.)
It is currently not working like i intended.
If you only want to know if the search string was in the file, and don’t care on which line, then
strpos()(doc) withfile_get_contents()might be for you like this:If you want to know the line, your solutions should work as well if you change the
if($line == $search)with mystrpos().If the line has to be exactly the search query you are looking for, then your solution should work just fine