Textarea list into MySql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Trommil
Forum Newbie
Posts: 3
Joined: Tue Nov 30, 2004 2:04 pm

Textarea list into MySql

Post by Trommil »

I've been trying to find an easy way to put a list of about 100 email addresses into a MySQL database using PHP (these are people who want their email addresses put in the database and not spam in any form).

So far I've come up with the idea of having a textarea where the list of email address can be pasted in from a Excel file (standard copy and paste). Each email address will be on a new line. What I need to do is be able to split the email addresses into seperate variables and then use a loop to put them into the database. I just can't figure out the best way to do this.

Any help would be gratefully appreciated.

Of course, if you can come up with a better method than I have please let me know.

Thanks.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

If you POST the form then you should be able to get an array of emails by doing:

Code: Select all

$emails = explode("\n", $_POST['emails']);
Trommil
Forum Newbie
Posts: 3
Joined: Tue Nov 30, 2004 2:04 pm

Post by Trommil »

Great, thanks for the reply. I'll give it a go.
Trommil
Forum Newbie
Posts: 3
Joined: Tue Nov 30, 2004 2:04 pm

Post by Trommil »

Worked a treat. I'll have to research $_POST. Makes me wonder what else I've missed.
Post Reply