0

Hi, I have this function in a class file Fileops.php which is suppose to read from a text file then validate a username and password from that text file then if they match will take me to Links.php when the function is called from index.php, but i am getting these errors:

Warning: file(../tmp/users.txt) [function.file.html]: failed to open stream: No such file or directory in /home/student/nguydn08/public_html/p2475/cinc/Fileops.php on line 123

Warning: Invalid argument supplied for foreach() in /home/student/nguydn08/public_html/p2475/cinc/Fileops.php on line 125

public function validateUser( $username, $password) {

		
		$file_link = "../tmp/users.txt";
		$lines = file($file_link);
		
		foreach($lines as $line_num => $line){
			$decodedline = urldecode($line);
			$pieces = explode("::", $decodedline);
			if ( $username == $pieces[0] && $password == $pieces[1] ) { 
				header( 'Location: http://bscacad2.buffalostate.edu/~nguydn08/p2475/Links.php' ) ;
				return True;
			}
			else{
				header( 'Location: http://bscacad2.buffalostate.edu/~nguydn08/p2475/index.php' ) ;
			    
		}}
     } 

 }
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by saiprem
0

It seems you don't have file in the specified location
$file_link = "../tmp/users.txt";

Also you need to specify the exact path something like
/var/tmp/users.txt

or

/home/tmp/users.txt

or

/tmp/users.txt

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.