I have a text file with a list of names in it. I want to make a web page with a form so that when the user submits a name, my PHP script returns that the name either is or isn't on the list.
Here is the HTML for my index.htm page, which has the form on it:
Code: Select all
<html>
<title>You have come to my website.</title>
<body>
Please enter your name below.
<form action="login.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p><input type="submit" value="Login" /></p>
</form>
</body>
</html>Code: Select all
<?php
$vname=$_POST["name"];
$uname="";
$namefile=fopen(("users.txt"),"r+");
while (!feof($namefile) && !($vname==$uname)
{
$uname=fgets($namefile);
}
if ($vname==$uname)
{
echo "user name found";
}
else
{
echo "user name not found";
}
fclose($namefile);
?>If I comment out the file-reading part of login.php (lines 5-17), the script works fine. But when that part is executed, Explorer just gives me an HTTP 500 "The page cannot be displayed" error.
I don't have any kind of debugging environment, all I can do at present is write the code in a text editor and run it by putting the page's URL in my browser. So I don't get any specific error messages.
How can I make this work?