I'm trying to write a code that compares the values from a text document with a value that has been posted from a form.
So far i've got this, but i'm absolutely positive i'm doing something way off.
Thanks in advance for your help!
<form method="POST" action="file.php">
<p>
<br /><input type="text" name="name" ><br />
</p>
<p><input type="submit" value="Check" /></p>
</form>
<?php
if (isset($_POST['name'])) {
$name = $_POST['name'];
/*The text document contains these written names:
Michael
Terry
John
Phillip*/
$lines = file('names.txt');
$names_array = ($lines);
if (in_array($name, $names_array)) {
echo "exists";
} else {
echo 'none';
}
}
?>
UPDATE: Fixed and now working fine!