focus Posted December 10, 2008 Share Posted December 10, 2008 Whats wrong with my code? This is meant to send form details to an email address <?php function is_valid_email($from_email) { return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si', $from_email); } $to_mail = "blaaah@hotmail.com"; $subject = "Register"; $firstname.=$_POST['firstname']."\n" ; $lastname.=$_POST['lastname']."\n" ; $gender.=$_POST['gender']."\n" ; $dob.=$_POST['dob']."\n" ; $dancename.=$_POST['dancename']."\n" ; $crewname.=$_POST['crewname']."\n" ; $suburb.=$_POST['suburb']."\n" ; $dancestle.=$_POST['dancestle'] ."\n" ; $from_email.=$_POST['from_email'] ."\n" ; $experience.=$_POST['experience'] ."\n" ; $message = " <html> <head> <title>Dance Registration</title> </head> <body bgcolor=#F3F3F3> <TABLE CELLSPACING=2 CELLPADDING=2 BORDER=0> <TR BGCOLOR=#FFFFFF> <TD COLSPAN=2></TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>First Name:</TD> <TD>$firstname</TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>Last Name:</TD> <TD>$lastname</TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>Gender:</TD> <TD>$gender</TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>DOB:</TD> <TD>$dob</TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>Dance Name:</TD> <TD>$dancename</TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>Crew Name:</TD> <TD>$crewname</TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>Suburb:</TD> <TD>$suburb</TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>E-mail Address:</TD> <TD><$email_address</A></TD> </TR> <TR BGCOLOR=#FFFFFF> <TD>Experience:</TD> <TD>$experience</TD> </TR> <TR> <TD COLSPAN=2></TD> </TR> </TABLE> </body> </html> "; $sent = mail($to_email, $subject, $message) ; if($sent) {print "Your mail was sent successfully."; } else {print "We encountered an error sending your mail"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/ Share on other sites More sharing options...
haku Posted December 10, 2008 Share Posted December 10, 2008 $to_mail != $to_email Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/#findComment-711155 Share on other sites More sharing options...
focus Posted December 10, 2008 Author Share Posted December 10, 2008 sorry i dont get it? Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/#findComment-711538 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Please use the [ code] [ /code] (without the space in those tags) to post code in. //$to_mail = "blaaah@hotmail.com"; change this to $to_email $to_email = "blaaah@hotmail.com"; $subject = "Register"; $firstname.=$_POST['firstname']."\n" ; $lastname.=$_POST['lastname']."\n" ; $gender.=$_POST['gender']."\n" ; $dob.=$_POST['dob']."\n" ; $dancename.=$_POST['dancename']."\n" ; $crewname.=$_POST['crewname']."\n" ; $suburb.=$_POST['suburb']."\n" ; $dancestle.=$_POST['dancestle'] ."\n" ; $from_email.=$_POST['from_email'] ."\n" ; $experience.=$_POST['experience'] ."\n" ; Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/#findComment-711543 Share on other sites More sharing options...
focus Posted December 10, 2008 Author Share Posted December 10, 2008 But then how does it know to which email to send it to? Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/#findComment-711569 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 But then how does it know to which email to send it to? The point was in the mail function, you were using $to_email, and in your variable declaration you were using $to_mail, since $to_mail is not the same as $to_email you needed to switch one. I chose to switch the $to_mail, to be $to_email. Look at the line below the // it is not $to_email. Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/#findComment-711573 Share on other sites More sharing options...
Brian W Posted December 10, 2008 Share Posted December 10, 2008 translation if you didn't get that. be sure u only use $to_mail or $to_email, because they are not the same and php will not interpret them as the same. also watch out on caps, php variable and custom functions are case sensitive. Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/#findComment-711581 Share on other sites More sharing options...
focus Posted December 11, 2008 Author Share Posted December 11, 2008 oooooh how stupid of me... Thanks alot! =) Quote Link to comment https://forums.phpfreaks.com/topic/136319-solved-my-php-wont-send-to-email/#findComment-712202 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.