damienwc Posted April 11, 2007 Share Posted April 11, 2007 Basically what i'm trying to do is when a user inputs login/password information at a login page, I want PHP to search inside verify.txt and if it finds the login/password combination then allows the user to proceed. Is this possible? And if so, which functions would I use to get the job done? Also, how can I save the login name so that it can be passed to/included in a url? Link to comment https://forums.phpfreaks.com/topic/46549-can-i-use-php-to-search-for-a-specific-word-inside-a-text-file/ Share on other sites More sharing options...
ryeman98 Posted April 11, 2007 Share Posted April 11, 2007 Wouldn't it be easier just to use a database? You would have a lot more security... Link to comment https://forums.phpfreaks.com/topic/46549-can-i-use-php-to-search-for-a-specific-word-inside-a-text-file/#findComment-226597 Share on other sites More sharing options...
rameshfaj Posted April 11, 2007 Share Posted April 11, 2007 first open the file thats content has to be read.Then u can split the input from the file according to space,this gives u the words in the file.Note that after splitting the content of the file are converted into an array.Now according to the length of the array iterate and compare the values in the array with the one which u want to search for.I hope this helps u. Link to comment https://forums.phpfreaks.com/topic/46549-can-i-use-php-to-search-for-a-specific-word-inside-a-text-file/#findComment-226614 Share on other sites More sharing options...
rpadilla Posted April 11, 2007 Share Posted April 11, 2007 you'll need to use fopen to open your file check it out here www.php.net/fopen <?php $handle = fopen("\home\username\verify.txt", "rb"); $contents = ''; while (!feof($handle)) { $contents = fread($handle, 8192); echo $contents; } fclose($handle); ?> you should put your user/password per line Link to comment https://forums.phpfreaks.com/topic/46549-can-i-use-php-to-search-for-a-specific-word-inside-a-text-file/#findComment-226637 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.