Hello. I have attempted to create this script that uses the fgetcsv function to check if the username and password on a line of a csv file correspond with the username and password that a user enters into a form. It seems to be working however i get the following error message when the code is run
Warning: fgetcsv(): 2 is not a valid stream resource in D:\minixammp\fgetcsv.php on line 13
NB: Line 13 is the while statement.
Can anyone help me out with this one???
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<?php
$row = 1;
$handle = fopen("members.csv", "r");
while ($data = fgetcsv($handle, 1000, ",")) {
if ($_POST['username'] == $data[0] & $_POST['password'] == $data[1]){
echo "<p> Your Username and password combination is correct, you will be redirected to info.php";
}
$row++;
echo ("The username and password you specified is incorrect");
fclose($handle);
}
?>
</body>
</html>