I am a Fedora 10 user. I want to create a form that can accept form data and save it to a file. For that, I used the following code, but the file (names.txt) was not created. Can someone please tell me what to do??
<html>
<head></head>
<form method="POST">
<pre>
</br> First Name <input type="text" name="first"/>
</br> Last Name <input type="text" name="last"/>
</br> <input type="submit" value="Save the data"/>
</pre>
</form>
<?php
$fp = fopen("./names.txt",'a');
if($_POST['first'] and $_POST['last']){
$name= $_POST['first']." ".$_POST['last']."\n";
print($name);
fputs(fp,$name);
}
fclose($fp);
?>
</html>
Edited by Orjan, 08 February 2010 - 05:09 AM.
Please use code tags!


Sign In
Create Account

Back to top









