KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a file I need to import into a database. (My database is good, I can connect and I can add). Now my problem is for some reason nothing gets inserted. I have a file schooldatabase.txt of users/password I need to add to a database. The file has 200 lines. Here's a sample: test|098f6bcd4621d373cade4e832627b4f6 test2|ad0234829205b9033196ba818f7a872b Now for each of these line (student username and password) I have to insert them in a database. Here's my code: function addUser($user,$pass) { // this code is good } function processUser($user,$pass) { $pass=md5($pass); $myFile = "schooldatabase.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 5); $login = "$user|$pass"; if(stristr($theData,$login) !== false){ $result = "rejected"; } elseif(stristr($theData,$login) !== true){ addUser($user,$pass); // this work I manuall tested $result = "accepted"; } fclose($fh); return $result; } var_dump(processUser('invaliduser','test2')); Why it return "accepted" if that user is not in the file?
Tags (comma-separated)
Save Edits
Cancel