php feedback form writing to .txt file?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-13-2004
Lord Hart
 
Posts: n/a
Default php feedback form writing to .txt file?

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
Reply With Quote
  #2 (permalink)  
Old 05-13-2004
Niall Kavanagh
 
Posts: n/a
Default Re: php feedback form writing to .txt file?

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:15 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0