Jump to content

New line when appending a txt file with PHP


Emil_RDW

Recommended Posts

Hello everybody!

 

Keep in mind I'm new to PHP but get the basics :)

 

I'm trying to collect email addresses from a web-form that gets filled out on a website into a simple txt file on the server.  The problem is the emails get appended one right after the other with no spaces so it looks like "[email protected]@[email protected]" and so on.  What I'm trying to do is either separate them by a comma, or put them on a new line but whatever I try, it will not accept it.

 

Anyway, here is the code that I have:

 

$fp = fopen("/home/fullertr/public_html/email_collector.txt","a");
				fwrite($fp,$_POST['visitormail' . "\n"]);
				fclose($fp);
				unset($_POST);

 

Thanks for any help!

sorry it didn't work...just a shot in the dark..was worth a shot

 

Actually that helped me out!

 

I modified it to be on it's own and this actually works:

 

$fp = fopen("/home/fullertr/public_html/email_collector.txt","a");
				fwrite($fp,$_POST[" <br /> \n"]);
				fwrite($fp,$_POST['visitormail']);
				fclose($fp);
				unset($_POST);

 

Thanks a lot!  Now I have them going to a new line.  Now how can I separate them by a comma instead of a new line?

 

PFMaBiSmAd, I'm viewing the text file in the browser by going to the server.com/email.txt

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.