Hi guys,
I am working on my php script with the registerform so that I can send email to my clients, but the question is how I can submit the register form to be delay while it takes around 24 hours before it send the email to itself?
I am sure that it should be possible to do so, here's the code:
<?php
session_start();
define('DB_HOST', 'localhost');
define('DB_USER', 'myusername');
define('DB_PASSWORD', 'mypassword');
define('DB_DATABASE', 'mydbname');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
function clean($var){
return mysql_real_escape_string(strip_tags($var));
}
$username = clean($_GET['username']);
$password = clean($_GET['password']);
$email = clean($_GET['email']);
$firstname = clean($_GET['firstname']);
$lastname = clean($_GET['lastname']);
$country = clean($_GET['country']);
if($name == '' && $email == ''){
// both are empty
$errmsg_arr[] = 'Both name and email are missing. You must enter one or the other.';
$errflag = true;
}
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
echo implode('<br />',$errmsg_arr);
}
else {
$insert = array();
if(isset($_GET['username'])) {
$insert[] = 'username = \'' . clean($_GET['username']) .'\'';
}
if(isset($_GET['password'])) {
$insert[] = 'password = \'' . clean($_GET['password']) .'\'';
}
if(isset($_GET['email'])) {
$insert[] = 'email = \'' . clean($_GET['email']) . '\'';
}
if(isset($_GET['firstname'])) {
$insert[] = 'firstname = \'' . clean($_GET['firstname']) . '\'';
}
if(isset($_GET['lastname'])) {
$insert[] = 'lastname = \'' . clean($_GET['lastname']) . '\'';
}
if(isset($_GET['country'])) {
$insert[] = 'country = \'' . clean($_GET['country']) . '\'';
}
if (count($insert)>0) {
$names = implode(',',$insert);
if(isset($email)) {
$firstname = $_GET['firstname'];
$header .= 'From: Mysite Register <register@mysitename.com>' . chr(13) . chr(10);
$to = $email;
$subject = "Thank you for Signing up with us";
$message = "Dear $firstname,
Thank you for signing up with us. We have received your request to get your confirmation code before you become an active member. Please wait within 24 hours.
Thank you for signing up with us,
The Site Team
Please do not reply to this e-mail address. Mail sent to this address cannot be answered and will returns as undelivered.";
$header .= "MIME-Version: 1.0\l\n";
$add = "-f". "register@mysitename.com";
mail($to, $subject, $message, $header, $add);
echo "Thank you for signing up with us. Please check your email and get your confirmation code within 24 hours.";
}
}
}
?>
Any advice would be much appreciate.
Thanks,
Mark