writing from textareato txt file

Hello :slight_smile: I am a trying to write the content of a text area to a txt file. Using the following ode i get an error message saying that the variable example is not defined. Any help please…? :slight_smile:

this is my code:

[php]

<?php $area=$_POST["example"]; $fp=fopen("test.txt","w"); fwrite($fp, $area); fclose($fp); ?>

[/php]

You need to add the submit & form tags around the text area

[code]

[/code]

Thank you for the quick reply :slight_smile:

The variable example still appears as undefined though…any other ideas?

put something in the text area and post it is it still undefined ?

it is worked! i did as you said (i put smthng in the txtarea) and it is all fine now :slight_smile:
thanks a lot !!

I do not know what you are doing so I cannot add things as they might be something different to what you want I gae you what you wanted how to write with textarea other coding is up to you.
To check sanatize modify to your needs I can only guide.

Maybe you should do a check like

[php] if(isset($_POST[‘submit’])){
code
}[/php]

this is what i am actually trying to do:

i have a table with different forms as elements (i used the table just because this way it looks better). All the forms include text areas. These are the 2 basic functions :

1)when i open the page i want some of the forms to read data from some txt files. This is working fine.

2)i want to write the content of the rest forms (textareas) to some other txt files. The problem is that i want to do that with just one button so i tried adding it (the button) outside the forms and obviously this is not working.

How can i solve this?

Put the button back inside the form tags ?

OR you want more than one textarea to be added at the same time so if you had three one blew each other ?

[php]

<?php $area =$_POST["example"]; $area1 =$_POST["example1"]; $area2 =$_POST["example2"]; $fp=fopen("test.txt","w"); fwrite($fp, $area,$area1,$area2); [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service