Padgoi Posted November 25, 2006 Share Posted November 25, 2006 Ok, right now, it's just a file that displays a random line from a text file. Here is the current script:$myfile = 'random1.txt';if(file_exists($myfile)){$file = file($myfile);$lines = count($file) - 1;echo $file[rand(0, $lines)];}elsetrigger_error('File ' . $myfile . ' does not exist', E_USER_ERROR);Can anyone help me out with adding a search to it? I want people to be able to search their email address or password to see if they're in the text file. Can anyone help me with this, my php knowledge is very limited? Thank you in advance. Link to comment https://forums.phpfreaks.com/topic/28472-php-searching-a-text-file/ Share on other sites More sharing options...
Padgoi Posted November 26, 2006 Author Share Posted November 26, 2006 Ok, I have this to enter the thing the user is searching for:<form action="page.php" method="post"><fieldset><legend>Search Stolen Information</legend><label for="keyword">Email Address or Password:</label> <input type="text" id="keyword" name="search"><input type="submit" value="Search"></fieldset></form>Now I just need the php script in page.php that actually searched the text file for the thing the user wants to search for. Any help please? Link to comment https://forums.phpfreaks.com/topic/28472-php-searching-a-text-file/#findComment-130291 Share on other sites More sharing options...
JasonLewis Posted November 26, 2006 Share Posted November 26, 2006 well the file() function returns the contents in an array. well... how is each line set out. like does each user have a thing like this:[username]blah[password]blah[email]blahetc etc.how is it set otu? Link to comment https://forums.phpfreaks.com/topic/28472-php-searching-a-text-file/#findComment-130298 Share on other sites More sharing options...
Padgoi Posted November 26, 2006 Author Share Posted November 26, 2006 I got it, thanks for the help. Link to comment https://forums.phpfreaks.com/topic/28472-php-searching-a-text-file/#findComment-130380 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.