how to save the html form data into a text file?
i have a html form layout, i want to retrieve the input data entered by
the user in this form and save it in a text file, how to do this ?
HTML:
<form method="post" action="welcome.php">
Name: <input type="text" name="name" id="name" />
Email: <input type="text" name="email" id="email" />
<input type="submit" name="submit" value="Send Form" />
</form>
i have tried this php code for welcome.php, but it is not working, can you
indicate any mistakes in this code, PHP:
<?php
$file = $_POST['name'];
$email = $_POST['email'];
$ex = ".txt";
$write = fopen("$file$ex","w");
fwrite($write,$email);
fclose($write);
$data = "/localhost/";
rename ("$file","$data$file$ex");
header('Location: http:localhost/welcome.php');
exit;
?>
No comments:
Post a Comment