The information all comes for that signup form I linked. The send mail is at the very bottom...
// Signup Form Validation
$errorMsg = "";
// makes othergame into game if they enter another game
if($POST[game] == 'other')
$POST[game] = $_POST[othergame];
// time all leading and trailing spaces from the $POST array
$POST = array_map('trim', $_POST);
// check if required fields are empty
if(empty($POST[username])
|| empty($POST[password])
|| empty($POST[email])
|| empty($POST[firstname])
|| empty($POST[lastname])
|| empty($POST[age])
|| empty($POST[game])
|| empty($POST[yearsplayed]))
{
$errorMsg .= 'Please go back and fill in all required fields.<br>';
}
// check if username is valid
if(preg_match("/[\^<>\;.\ #|`\$\&]/", $POST[username]))
{
$errorMsg .= 'The username "'.$POST[username].'" is not valid.<br>';
}
// check if username exists already in the database
else if(empty($errorMsg))
{
$sql = mysql_query("SELECT 1 FROM members WHERE username = '$POST[username]';", $MySQL_connect);
if (mysql_num_rows($sql))
{
$errorMsg .= 'The username "'.$POST[username].'" is already in use.<br>';
}
}
if(empty($errorMsg))
{
$sql = mysql_query("SELECT 1 FROM members WHERE email = '$POST[email]';", $MySQL_connect);
if (mysql_num_rows($sql))
{
$errorMsg .= 'The email address "'.$POST[email].'" is already in use.<br>';
}
}
// check if age is valid
if(!is_numeric($POST[age]) || $POST[age] < 0 || $POST[age] > 150)
{
$errorMsg .= 'The age "'.$POST[age].'" is not valid.<br>';
}
// email/domain validation - http://forums.devshed.com/archive/t-73792
$validEmailExpr = "0-9a-z~!#$%&-" .
"@0-9a-z~!#$%&-$";
//set up server name from email address
$emailEx = explode('@',$_POST[email]);
$mailhost = $emailEx[1];
$mailhost=$mailhost.".";
//validate email format
if (!eregi($validEmailExpr, $_POST[email])) {
$errorMsg .= "The email address must be in the name@domain format";
}
//validate name server
elseif (!(getmxrr($mailhost, $temp)) || !(checkdnsrr(gethostbyname($mailhost), "ANY"))) {
$errorMsg .= "The email address domain does not exist";
}
// end email check
// print out all the errors...
if(!empty($errorMsg))
{
$errorMsg = '<font id="redtext"><b>The following errors have occurred. Please go back and correct them.</b><hr><a href="javascript:history.back()">Back</a><hr>'.$errorMsg;
}
else
{
$errorMsg = "<font>Sign up is complete! To validate your membership please check your email.<br><br>Being automaticly re-directed in 10 seconds...";
// makes page re-load to sign in page
$bodyOnLoad = "signinredirect();";
$joindate = time();
$validated = 0;
if(empty($POST[showemail]))
$POST[showemail] = 0;
mysql_query("INSERT INTO members (
username ,
PASSWORD ,
email ,
showemail ,
firstname ,
lastname ,
country ,
city ,
age ,
aol ,
yahoo ,
game ,
yearsplayed ,
bio ,
validated ,
joindate )
VALUES ( '$POST[username]',
'$POST[password]',
'$POST[email]',
'$POST[showemail]',
'$POST[firstname]',
'$POST[lastname]',
'$POST[country]',
'$POST[city]',
$POST[age],
'$POST[aol]',
'$POST[yahoo]',
'$POST[game]',
'$POST[yearsplayed]',
'$POST[bio]',
$validated,
$joindate
)", $MySQL_connect);
// send validation email
mail("$POST[email]", "Validate your Role Playing Journal membership",
"$POST[firstname] $_POST[lastname],
To activate your Role Playing Journal membership click the below link
http://www.roleplayingjournal.com/activatemembership.php?join=$joindate&username=$_POST[username]
Thank You,
-RPJ
", "From: RPJ <webmaster@roleplayingjournal.com>");
}
// includes header file and prints error/msg
include("templates/header.inc");
echo '<center>'.$errorMsg;
?>