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 "user@server.comuser2@server.comuser3@server.com" 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!

Link to comment
Share on other sites

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

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.