At 3/23/06 07:40 PM, liljim wrote:
The nightly mails from Newgrounds go out to well over a quarter of a million people every night, half a million go on Wednesday night, and they're all formatted in HTML (although I'm debating as to whether or not to make that an option, so users who aren't able to receive HTML mails don't).
These are nice stats... Nice ? Heh, nice is an acronym for great++ [not ending loop :D ]
Okay, newsletter.
You must have a mysql database and php enabled page. Then, make a form where the user will enter it's email address.
Then, just insert that stuff into a mysql db and go further. It'll look something like:
<?
//scripted on the bbs, so no kills for the syntax. some odd errors may
// occur. This is a BBS!
?>
....
<form name="newsletter" id="newsletter" method="post" action="<?=$PHP_SELF?>">
<label>
Your email here
<input type="text" name="mails" size="50">
</label>
<input type="submit" value="Submit!" name="n_submit">
</form>
.....
<?
//process
//put some globals
$mail = $_POST['mails'];
$n_button = $_POST['n_submit'];
// if submited
if ($n_button = 'Submit!') {
# a regular smal selfcheck
if ($mail == "" && empty($mail) ) {
echo "You haven't entered any email";
echo "<br /> \n";
die("Please try again. [a href=\"javascript: history.back();\"]Go Back[/a]");
// replace [ with < and ] with >
}
/* for bigger security you can add a email preg_match function */
$conn = mysql_pconnect (localhost, $username, $password) or trigger_error ("Error: ".mysql_error());
// mysql_pconnect is better
//replace $username and $password with your own username
// and password
//if an error occurs, we won't stop the whole app (even though it is recommended in
// this case. We'll just output errors.
mysql_select_db ($db) or trigger_error("Cannot select the db");
// select the db.
// replace $db with your own mysql database name
$tbl = "your table name"; //replace with your table name
$field = "your field name"; //replace with your field name
$sql = "INSERT INTO $tbl ($field) VALUES ($mail)"; // no needs to replace
mysql_query($sql) or trigger_error ("Cannot add the email $mail to the system");
// done
echo 'Done! \n';
// this can flood your inbox, but if you want to have it...
mail('your@email.com', 'New Newsletter User', "An user with email <strong>$mail</strong> has just joined!");
}
?>
===
That's it. Now you just have to set up the newsletter thing.
It would like :
<?
--- a message
--- submit
---- process
------- select emails from $tbl
--------send newsletter
?>
Hope I helped!