Please ignore the "read" select option. I am still learning write and append for now. and I wanted to come up with a script that does those two things for me for now before I add more functionality to it. But the error message, that has been displayed below(check the "Error message" picture please) just won't go away.
<?php
$file_handler = fopen('list_of_names.txt', $choice);
if(isset($_POST['action'])){
$choice = $_POST['action'];
echo $choice;
}
if(isset($_POST['name'])){
$enterd_name = $_POST['name'];
if(!empty($_POST['name'])){
fwrite($file_handler, $enterd_name."\n");
}
}
fclose($file_handler);
?>
<form action="file_handling.php" method="POST">
<label for="name">Name: </label>
<input type="text" name="name"><br><br>
<select name="action">
<option value="a">Append</option>
<option value="w">re-write</option>
<option value="r">read</option>
</select><br><br>
<input type="submit" value="Submit">
</form>