hey im tryin to mail the username and a random generated password to a user with the following code:
It inserts the registration details into the database and generates the password but it just won't email the details!!
I have noticed that it takes awhile for it to enter the info!!!
Any help would be really great!!
$Q01 = "SELECT *
FROM $dbtable
WHERE UserName = '$UserName'";
$R01 = odbc_exec($db,$Q01) or die("Bad Q01:".mysql_error());
$A01 = odbc_fetch_into($R01, $A11);
if($A01 != 0)
{
echo( "That UserName Already Exists, Please Chose Another!");
//@header("Location: //register.php?ErrorCode=$ErrorCode&FirstName=$FirstName&LastName=$LastName&UnitNumber=$UnitNumber&Email=$Email&WebSite=$WebSi//te");
exit;
}
$Q02 = "SELECT *
FROM $dbtable
WHERE Email = '$Email'";
$R02 = odbc_exec($db,$Q02) or die("Bad Q01:".mysql_error());
$A02 = odbc_fetch_into($R02, $A12);
if($A02 != 0)
{
echo( "That Email Is Already Reistered!");
exit;
}
function makeRandomPassword()
{
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7)
{
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$random_password = makeRandomPassword();
$db_password = md5($random_password);
$Q03 = "INSERT INTO $dbtable VALUES ('',0,'$UserName', '$FirstName', '$LastName','$db_password', '$Email')";
$R03 = odbc_exec($db,$Q03) or die("BadQ03");
$A02 = odbc_fetch_into($R02, $A12);
if(!$Q03){
echo 'There has been an error creating your account. Please contact the webmaster.';
}
else {
//$userid = odbc_insert_id();
// Let's mail the user!
$subject = "Your Membership at MyMusic!";
$message = "Dear $first_name $last_name,Thank you for registering at our website You are two steps away from logging in and accessing our exclusive member To activate your membership, please click here: [url]http://support.deft.ie/activ[/url]$/activate.php?id=$userid&code=$db_password Once you activate your membership, you will be able to login withn the following information Username: $username Password: $random_password Thanks! The Webmaster This is an automated response, please do not reply!";
$mailheaders = "From: Deft Consulting";
mail($Email, $subject, $message, $mailheaders);
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?>
Thanx!!