Reply
Submit form to document.
Old 11-08-2004, 10:33 PM Submit form to document.
Skilled Talker

Posts: 81
Location: New York
Hello i want to make a submit action for a form so that i can write to a file what is in the textare box. Please i need help a.s.a.p. thanks
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
When You Register, These Ads Go Away!
Old 11-08-2004, 11:33 PM
Skilled Talker

Posts: 68
Location: Georiga
its quite easy you have the form page and have it post to a new page.
form.php

HTML Code:
<form action="add.php" method="POST"> 
<textarea rows='3' name='textbox' cols='45'>
<input type="Submit" name="submit" value="Enter">
</form>
the use this code to process this data.

add.php
PHP Code:
<?php
$text 
$_POST[textbox];   // Gets the text from the previous page
$file "document.txt";       // Make sure the chmod is 777(everyone read and write)
$open fopen($file,'a+');  // Opens the file and places the insert point at the end of the file
fwrite($open$text)           // Writes the text to the file
fclose($open);                   // Closes the file
echo "Done";


?>
__________________
Nobody is offline
Reply With Quote
View Public Profile Visit Nobody's homepage!
 
Old 11-09-2004, 08:10 AM
Skilled Talker

Posts: 81
Location: New York
yes thanks i just couldnt get it working for some reason =]
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
Old 11-09-2004, 10:17 AM
Skilled Talker

Posts: 68
Location: Georiga
__________________
Nobody is offline
Reply With Quote
View Public Profile Visit Nobody's homepage!
 
Old 11-09-2004, 03:49 PM
Skilled Talker

Posts: 81
Location: New York
ok i get an error on line 6
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
Old 11-09-2004, 03:53 PM
Skilled Talker

Posts: 81
Location: New York
Parse error: parse error, unexpected T_STRING in /www/f/fgc4l/htdocs/___/includes/dailychange.php on line 6
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
Old 11-09-2004, 11:09 PM
Skilled Talker

Posts: 68
Location: Georiga
sorry forgot the ; after fwrite($open, $text)

so it should be fwrite($open, $text);
__________________
Nobody is offline
Reply With Quote
View Public Profile Visit Nobody's homepage!
 
Old 11-10-2004, 08:25 AM
Skilled Talker

Posts: 81
Location: New York
lol omg i cant believe i didnt see that
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
Old 11-10-2004, 08:30 AM
Skilled Talker

Posts: 81
Location: New York
ok how would i have it over write the content already there?
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
Old 11-10-2004, 10:53 AM
Skilled Talker

Posts: 97
To overwrite the contents of a file, just open the file using the w+ instead of an a+

i.e. change:
$open = fopen($file,'a+');

to

$open = fopen($file,'w+');
daboss is offline
Reply With Quote
View Public Profile Visit daboss's homepage!
 
Old 11-10-2004, 01:26 PM
Skilled Talker

Posts: 81
Location: New York
ok sounds good thanks =]
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
Old 11-11-2004, 01:07 PM
Skilled Talker

Posts: 68
Location: Georiga
hehe is a list of all the commands of fopen

'r' Open for reading only; place the file pointer at the beginning of the file.

'r+' Open for reading and writing; place the file pointer at the beginning of the file.

'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.

'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.

'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.


'x+' Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
__________________
Nobody is offline
Reply With Quote
View Public Profile Visit Nobody's homepage!
 
Reply     « Reply to Submit form to document.
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15747 seconds with 12 queries