How to do this--> Textarea frpm php to a txt

TheMatrix

BANNED
Joined
Dec 20, 2008
Messages
3,439
Reaction score
7,401
Hey all

I have made a php file which extracts emails from facebook. It shows emails on a new page, in a textarea.

I want to ask, how can I automatically save results in a txt file when the emails are shown up.

I mean this:

I start script.--> 100 emails extracted--> Shown in box--> Saved in txt file like this:
email1
email2
email3..


I start script.--> 200 more emails extracted--> Shown in box--> Saved in txt file like this:

email1
email2
email3
email4
email5
email6..


Please help me,,

Thanks
 
since you wrote a base app already im assuming you know how to POST an html form to php.

PHP:
$emails = $_REQUEST['textarea_name_here'];
$file = "txt_file.txt";

if ($emails) {
   $handle = fopen($file,'w');
   fwrite($handle,$emails);
   fclose($handle);
} else {
   echo "No emails entered";
}

that should do it, so create a form with a text area and a submit button, change the textarea name to match in the $_REQUEST and it should work, i haven't tested it but it should get you started.
 
PHP:
$fp = fopen($file, 'a');
or
$fp = fopen($file, 'a+');

Use a or a+ mode so the new email list will be appended to current file :)
 
PHP:
$fp = fopen($file, 'a');
or
$fp = fopen($file, 'a+');

Use a or a+ mode so the new email list will be appended to current file :)
 
@cyrix : Thanks for the code. But, I need it to be automatic. No need of any button.
 
@cyrix : Thanks for the code. But, I need it to be automatic. No need of any button.
 
@cyrix : Thanks for the code. But, I need it to be automatic. No need of any button.

I'm not sure what you wrote your script in, but just add a subroutine to send an HTTP POST Request to your PHP page. That's all a button does anyway.
 
Back
Top