Current location: Hot Scripts Forums » Programming Languages » PHP » Form Results To Text File


Form Results To Text File

Reply
  #1 (permalink)  
Old 09-25-04, 11:46 AM
bxcheats bxcheats is offline
Newbie Coder
 
Join Date: May 2004
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Form Results To Text File

Here is what I have so far.

Form:

<form name="form1" method="post" action="submit.php">
TEXTAREA NAME=usertxt COLS=20 ROWS=5></TEXTAREA>
<p align="center">
<input type="submit" name="Submit" value="Submit">
</p>
</form>

Submit.php:

<?
$fp=fopen("usertxt.txt","w");
fwrite($fp,addslashes($usertxt));
fclose($fp);
Header("location: index.html");
exit();
?>

What I want it to do is add on to the text file, not delete everything in it and add what the form says. For example I type "Joe" in on one day and the next day I type "Bob". The text file should read:

Joe
Bob

Does anyone know how to do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-25-04, 05:51 PM
Eclipse's Avatar
Eclipse Eclipse is offline
Coding Addict
 
Join Date: May 2004
Location: Long Island, New York
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
Change submit.php to:
PHP Code:

$file "usertxt.txt";

$fp1 fopen($file,"r");
$contents fread($fp1filesize($file));
fclose($fp1);
$fp=fopen($file,"w");
$add addslashes($usertxt) . '\n' $contents;
fwrite($fp,$add);
fclose($fp);
Header("location: index.html");
exit(); 
Well hope that works...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-25-04, 09:36 PM
mikaelf mikaelf is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: php[dot]net
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
you can simply use fopen modifier 'a' (append)
PHP Code:

$fp=fopen('usertxt.txt','a');

fwrite($fp,addslashes($usertxt));
fclose($fp);
header('location: index.html');
exit(); 
__________________
Useful PHP links:
bugs.php.net - for reporting PHP bugs
pear.php.net - PHP extension and application repository
pecl.php.net - get non standard PHP modules, submit yours
www.phpclasses.org - PHP classes repository
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Results to an HTML or Text File bxcheats PHP 3 09-25-04 11:46 AM
Excel document containing records, need to save as a text file to upload to mysql bearslife PHP 1 06-05-04 04:24 AM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 08:19 PM
Editing a text file. cjh_60 PHP 1 10-14-03 04:59 PM
Need to submit form to database and text file - Any ideas how? dpreiss ASP 1 08-21-03 07:02 PM


All times are GMT -5. The time now is 10:23 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.