Email sign-up

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
hshigs
Forum Newbie
Posts: 11
Joined: Tue May 24, 2005 9:38 am

Email sign-up

Post by hshigs »

Searched the forums and not sure what to look under or corret terms to use in searching. Am hoping for some help! I am interested in learning how to make an email sign up form and how to code it so that the emails are entered into the proper files so that I can upload them into a email client either online or something like Outlook. Or what is the normal way people would do something like that. I am completely starting from scratch on this one and don't know the nature of even how to ask the question. Are you able to typically have someone submit an email address and have code that adds it directly to your email list or do you have it send to a seperate file that you you recieve daily and then add them manually. I am trying to learn this so that I can offer this to my clients and I am just starting out with my business. I typically specialize in Flash driven presentational sites without a ton of backend but I am wanting to break into other various areas so I can improve upon my offerings. Is this something that you can even do with PHP or am i looking in the wrong place? Many thanks for you time, it is much appreciated!! Many Blessings!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

typically the address and potentially some additional parameters are stored in a database table.

The emails can be sent directly from the server using the proper set up.. we've talked about mass-mail a lot here...
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

You could store them in a database table, then export them to a .csv file.. since most mass mailing programs accept .csv files for mailing.

Find a way to get your stored email addresses into a comma delimited ( like email1,email2,email3, etc.) list, and you should be good to go.

A simple way to get the emails into a database table (which you do not have to add manually every day) would be

Code: Select all

<?
if($_POST['action'] == "submitemail")
{
     $email = mysql_real_escape_string($_POST['email']);
     mysql_query("INSERT INTO table (email) VALUES('$email')") or die(mysql_error());
     echo "Your email address has been added to the mailing list!";
} ELSE
{ ?>

<form action="<? echo $_SERVER['php_self']; ?>" method="post">
<input type="hidden" name="action" value="submitemail">
Emall Address: <input type="text" name="email" size="20"><BR>
<input type="submit" value="Submit">
</form>

<? } ?>
Then when you want to export this list to a csv file, store your database emails into an array and then write it to a csv file, something like the following:

Code: Select all

<?php

$list = mysql_fetch_assoc(mysql_query("SELECT email FROM table ORDER BY email ASC"));

$fp = fopen('file.csv', 'w');

foreach ($list as $line)
{
   fputcsv($fp, split(',', $line));
}
fclose($fp);

// this example taken from (but altered) http://us3.php.net/manual/en/function.fputcsv.php
?>
Post Reply