Sam Granger
06-21-2004, 06:33 AM
Hi, I want to make a form that people fill in and then can submit. I want the submitted info to get written to a txt file. How should I do this (planning to use fwrite). I want to use php aswell as the html form.
Cheers,
Sam
Well you basically answered your own question, just fwrite or fputs the content of your input field/textarea to a text file.
if($_POST['writedata'])
{
$fp = fopen("file.txt", "a");
fputs($fp, "".$_POST['input_name']."\n");
fclose($fp);
}
echo '<form name="blah" method="post" action="">
<input name="input_name" type="text">
<input name="writedata" type="submit">
</form>';
Sam Granger
06-21-2004, 09:30 AM
hmm, thanks
I tried the following:
<?php
if($_POST['request'])
{
$fp = fopen("requests.txt", "a");
fputs($fp, "".$_POST['input_name']."\n");
fclose($fp);
}
echo '<form name="requestform" method="post" action="">
<input name="Your Name:" type="text">
<input name="Your phone nr.:" type="text">
<input name="Request appointment with:" type="text">
<input name="Reason for request:" type="text">
<input name="Prefered date:" type="text">
<input name="request" type="submit">
</form>';
?>
I also made a seperate requests.txt
The ting is, even when I filled in the form, I don't get anything in the txt file. Also, just to make it clear, after the form gets filled in again, I don't want the previous saved data to disapear.
Please help!
Cheers,
Sam:rolleyes: