Page 1 of 1

Textarea list into MySql

Posted: Tue Nov 30, 2004 2:13 pm
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.

Posted: Tue Nov 30, 2004 2:22 pm
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']);

Posted: Tue Nov 30, 2004 2:35 pm
by Trommil
Great, thanks for the reply. I'll give it a go.

Posted: Wed Dec 01, 2004 12:12 pm
by Trommil
Worked a treat. I'll have to research $_POST. Makes me wonder what else I've missed.