I am trying to save the data entered in HTML form in a text file. I am using a php script to do this. When I click on submit button, it does not save the data in text file. Can someone tell me what is going wrong here.
Below is the code snippet -
HTML Form -
<form id="post" name="post" method="post" action="input.php">
Name: <input type="text" name="name"><br>
Text: <textarea rows="50" cols="85" name="blogentry"></textarea>
<input class="button" type="submit" value="Submit">
</form>
PHP - (input.php)
<html>
<head></head>
<body>
<?php
// variables from the form
$name = $_POST['name'];
$blogentry = $_POST['blogentry'];
// creating or opening the file in append mode
$dataFile = "data.txt";
$fh = fopen($dataFile, 'a');
// writing to the file
fwrite($fh, "Name - " . " " . $name . " " . "
");
fwrite($fh, "Blog - " . " " . $blogentry . " " . "
");
fclose($fh);
?>
</body>
</html>