View Full Version : Help in a php coding problem !!

04-03-2010, 12:52 AM
Hello i`m running a website for my workshop , i would like to make a forum that will have 2 text boxes and one button .
The first text box will be called : Suggestion: [Text box] , under this one there will be one called: E-mail: [Text box] , and under this one will be a Send button .
Now is the question , i will want users to type their suggestions in the text boxes , and when they press the Send button , to automaticly write the suggestion and the e-mail in a text document , each suggestion and e-mail separated by a line , and allways adding a new line in the same document , withouth erasing the previous suggestions etc . Sorry for my bad languace , i`m waiting, for your responses, thank you .

Len Whistler
04-03-2010, 01:27 AM
Not fully tested and will need some fine tuning.

$comments = $_POST['comments'];
$email = $_POST['email'];

$myFile = "data.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, "$comments\n");
fwrite($fh, "$email\n ---------------------------");
<form method="post" action="index.php">
<input type="text" name="email"><br>
<textarea rows="8" cols="105" name="comments"></textarea><br>
<input type="submit" value="Submit" name="submit">


04-03-2010, 02:26 AM
Why wouldn't you want to use a database? why to a text file? Curious...

04-03-2010, 10:45 AM
i dont have a database , and for something this simple , i dont want to make a datebase ..
or is there anyoter way .. like making a javescript code.. submitLoginForm() that will take the data from Comments and e-mail and put them in a text document?