Click to See Complete Forum and Search --> : A simple problem that i just cant solve


popcop
07-10-2007, 03:18 PM
My eyes have been glues to the screen all night long and i still cant seem to solve this problem...

Below is the code im using to send the users details to the database and then email them confimation link to complete their registration

it then shows a page which says "an email has been sent to your account to complete your registration"


Im gettin the error:
Cannot send Confirmation link to your e-mail address

heres the code
<?

// these headers are for the purpose of sending the email replay to hotmail and yahoo addresses
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: LEMON AND LIME RECORDS <hello@lemonandlimerecords.com>\r\n";
$headers .= "Reply-To: <hello@lemonandlimerecords.com>\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409\r\n";
$headers .= "X-Mailer: Microsoft Outlook Express 6.00.2800.1409";

// Assuming DB connect in config.php //
include('config.php');

// table name
$tbl_name="temp_members_db";

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$firstname = mysql_real_escape_string($_POST['firstname']);
$surname = mysql_real_escape_string($_POST['surname']);
$email = mysql_real_escape_string($_POST['email']);
$location = mysql_real_escape_string($_POST['location']);
$sex = mysql_real_escape_string($_POST['sex']);

// Insert data into database
$sql = "INSERT INTO $tbl_name (confirm_code, firstname, surname, email, location, sex)VALUES('$confirm_code', '$firstname', '$surname', '$email', '$location', '$sex')";
$result = mysql_query($sql) or die("SQL Error: $sql<br>" . mysql_error());

// if suceesfully inserted data into database, send confirmation link to email
if($result){

// ---------------- SEND MAIL FORM ----------------
mail("$email","LEMON & LIME RECORDS REGISTRATION", "<img src=\"http://www.popcop.co.uk/lemonandlime/register/smalllogo.gif\" width=\"150\" height=\"110\">
</p>
<p>Hello $firstname,</p>
<p>This is just a quick email to complete your registration</p>
<p>Simply <a href='http://www.popcop.co.uk/lemonandlime/register/confirmation.php?passkey=$confirm_code'>CLICK HERE</a> and thats you finished :)</P>
<P>Thanks!</p>
<P>*******************************************************************</P>
<p>
<P>MATT HUGHES - GIVE IT A TRY ep<BR>
AVAILABLE ON FRIDAY 3RD AUGUST 2007<BR>
FROM JUNODOWNLOAD.COM - BEATSDIGITAL.COM - ITUNES - NAPSTER - MUSICNET - EMUSIC
<P>*******************************************************************", $headers);

// send email
$sentmail = mail($to,$subject,$message,$header);

}

// if not found
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "<style type='text/css'>
<!--
body {
background-image: url(images/bg.jpg);
}
-->
</style></head>

<body>

<div align='center'>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img src='images/confirmation.png' alt='confirmation' width='640' height='365' />
</p>
</div>
</body>";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>

popcop
07-10-2007, 04:09 PM
solved the problem

hastx
07-10-2007, 04:17 PM
You are using 2 mail functions...in the second...

// send email
$sentmail = mail($to,$subject,$message,$header); // $to is never defined above

}
else {
echo "Not found your email in our database";
}

if($sentmail){ //..... here you are are saying " if successful with
//'mail($to,$subject,$message,$header)' " ......
//...since $to isn't defined as a valid email
//variable, mail cant be sent to it...therefore ...
//your getting ...

else {
echo "Cannot send Confirmation link to your e-mail address";
}