This is a discussion on php feedback form writing to .txt file? within the PHP General forums, part of the PHP Programming Forums category; Hello, I've only recently started using PHP and I've been trying to get a feedback form working which ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello, I've only recently started using PHP and I've been trying to
get a feedback form working which would write to a .txt file, the results of the feedback which would include the name, email, comments of the user. I had been using ASP before I started PHP, and I got it working with it, but when I uploaded it to my site, I discovered it didn't have any ASP support, unless I payed for it (and it costs more than the website itself). I have asked some people I know at a forum that I frequent, but to no avail, it doesn't work. Does anybody think they could help me? The following is all the HTML that has any link to the form in a file called feedback.html <form action="feedback.php" method="post"> <input type="textarea" name="name" /> <input type="textarea" name="email" /> <textarea rows="5" cols="25" name="comments"></textarea> <input type="submit" value="Submit Comment" /> <input type="reset" /> </form> And the following is the PHP, in a file called feedback.php: <?php import_request_variables('gP','r_'); // imports request variables - you may or may not have to do this $f=fopen('feedback.txt','a'); // opens feedback.txt for appending fwrite($f,"$r_name\n$r_email\n\n$r_content\n====== =================\n"); // adds stuff to the file, assuming the fields are called "name", "email" and "content" fclose($f); ?> My web server has PHP4 installed on it. If anyone can help me, then, I'd be very grateful. -- Lord Hart |
|
|||
|
Lord Hart <tdrlordhart@hotmail.com> wrote:
> import_request_variables('gP','r_'); // imports request variables - > you may or may not have to do this > $f=fopen('feedback.txt','a'); // opens feedback.txt for appending > fwrite($f,"$r_name\n$r_email\n\n$r_content\n====== =================\n"); > // adds stuff to the file, assuming the fields are called "name", > "email" and "content" > fclose($f); Do you get any error messages? Depending on the server config, you may not be permitted to write to files. Check (or ask) to see if safe_mode is enabled, or if open_basedir is used. If safe_mode is enabled, you will not be able to write to a directory that you do not "own". If open_basedir is specified, you will not be able to open files outside of directories specified. See the documentation for fopen for more details, and ask your provider what is available to you: http://www.php.net/manual/en/function.fopen.php -- niall |