jonnyroboto Posted April 21, 2009 Share Posted April 21, 2009 I created a form that works, except for the clarity of the info I'm receiving via email. Here is my code: <?php require_once('recaptchalib.php'); $privatekey = "..."; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("The reCAPTCHA wasn’t entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $num_adult = $_POST['num_adult'] ; $num_child = $_POST['num_child'] ; $num_room = $_POST['num_room'] ; $arrivemonth = $_POST['arrivemonth'] ; $arriveday = $_POST['arriveday'] ; $arriveyear = $_POST['arriveyear'] ; $nights = $_POST['nights'] ; $attractions1 = $_POST['attractions1'] ; $attractions2 = $_POST['attractions2'] ; $attractions3 = $_POST['attractions3'] ; $attractions4 = $_POST['attractions4'] ; $attractions5 = $_POST['attractions5'] ; $other_attractions = $_POST['other_attractions'] ; $embody = "<html><head></head><body><br /><br />"; $embody .= "Name: $name<br />"; $embody .= "Phone: $phone<br />"; $embody .= "Number of Adults: $num_adult<br />;" $embody .= "Number of Children: $num_child<br />;" $embody .= "Number of Rooms: $num_room<br />;" $embody .= "Arival MM/DD/YY: $arrivemonth/$arriveday/$arriveyear<br />;" $embody .= "Number of Nights: $nights<br />;" $embody .= "Attractions: $attractions1, $attractions2, $attractions3, $attractions4, $attractions5<br />;" $embody .= "Other Attractions Detail: $other_attractions;" $embody .= "</body></html> mail( "me@myemail.com", "Custom Vacation Package Form", $embody, "From: $email" ); header( "Location: http://www.mywebsite.com/thankyou.htm" ); ?> I am receiving an error that says: Parse error: parse error in /www/cgi/sendmail2.php on line 34. What am I doing wrong? Thank you, Quote Link to comment Share on other sites More sharing options...
rondog Posted April 21, 2009 Share Posted April 21, 2009 well look at line 34..you have ;" it should be "; you do that from line 34 down...and dont even have a close quote or semi colon on the last $embody Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted April 21, 2009 Share Posted April 21, 2009 Try this: semi-colons go on the outside of the quotes... <?php require_once('recaptchalib.php'); $privatekey = "..."; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("The reCAPTCHA wasn’t entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $num_adult = $_POST['num_adult'] ; $num_child = $_POST['num_child'] ; $num_room = $_POST['num_room'] ; $arrivemonth = $_POST['arrivemonth'] ; $arriveday = $_POST['arriveday'] ; $arriveyear = $_POST['arriveyear'] ; $nights = $_POST['nights'] ; $attractions1 = $_POST['attractions1'] ; $attractions2 = $_POST['attractions2'] ; $attractions3 = $_POST['attractions3'] ; $attractions4 = $_POST['attractions4'] ; $attractions5 = $_POST['attractions5'] ; $other_attractions = $_POST['other_attractions'] ; $embody = "<html><head></head><body><br /><br />"; $embody .= "Name: $name<br />"; $embody .= "Phone: $phone<br />"; $embody .= "Number of Adults: $num_adult<br />"; $embody .= "Number of Children: $num_child<br />"; $embody .= "Number of Rooms: $num_room<br />"; $embody .= "Arival MM/DD/YY: $arrivemonth/$arriveday/$arriveyear<br />"; $embody .= "Number of Nights: $nights<br />"; $embody .= "Attractions: $attractions1, $attractions2, $attractions3, $attractions4, $attractions5<br />"; $embody .= "Other Attractions Detail: $other_attractions"; $embody .= "</body></html>"; mail( "me@myemail.com", "Custom Vacation Package Form", $embody, "From: $email" ); header( "Location: http://www.mywebsite.com/thankyou.htm" ); ?> Quote Link to comment Share on other sites More sharing options...
jonnyroboto Posted April 21, 2009 Author Share Posted April 21, 2009 Thank you both so much. I feel dumb about that one. I did see that I forgot the close at the last embody too. I've been staring at code all day, and haven't eaten a thing to speak of. Seems to be working now that you all helped me with those silly mistakes. Thanks again ya'll. Quote Link to comment Share on other sites More sharing options...
rondog Posted April 21, 2009 Share Posted April 21, 2009 If you use a program like dreamweave it color codes the php and you can easily tell because items could like like strings when they shouldnt be Quote Link to comment Share on other sites More sharing options...
jonnyroboto Posted April 21, 2009 Author Share Posted April 21, 2009 I love dreamweaver. I'm fixing this form and the processing script server side because it allows me to test the php right there without using apache or anything. Quick question for you. Where would I put the code to render my emaill in html? I fixed the silly errors and now I'm getting all the html code with my form info. Quote Link to comment Share on other sites More sharing options...
rondog Posted April 21, 2009 Share Posted April 21, 2009 look into headers..you need to send headers along with the email otherwise you will see html characters Quote Link to comment Share on other sites More sharing options...
jonnyroboto Posted April 21, 2009 Author Share Posted April 21, 2009 I tried putting the headers in there but it gave me an internal server error. <?php require_once('recaptchalib.php'); $privatekey = "6LfD-wUAAAAAAA2-ZgXQuRi2_jPxMg197djp93ug"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("The reCAPTCHA wasn’t entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $num_adult = $_POST['num_adult'] ; $num_child = $_POST['num_child'] ; $num_room = $_POST['num_room'] ; $arrivemonth = $_POST['arrivemonth'] ; $arriveday = $_POST['arriveday'] ; $arriveyear = $_POST['arriveyear'] ; $nights = $_POST['nights'] ; $attractions1 = $_POST['attractions1'] ; $attractions2 = $_POST['attractions2'] ; $attractions3 = $_POST['attractions3'] ; $attractions4 = $_POST['attractions4'] ; $attractions5 = $_POST['attractions5'] ; $other_attractions = $_POST['other_attractions'] ; $embody = "<html><head></head><body><br /><br />"; $embody .= "Name: $name<br />"; $embody .= "Phone: $phone<br />"; $embody .= "Number of Adults: $num_adult<br />"; $embody .= "Number of Children: $num_child<br />"; $embody .= "Number of Rooms: $num_room<br />"; $embody .= "Arival MM/DD/YY: $arrivemonth/$arriveday/$arriveyear<br />"; $embody .= "Number of Nights: $nights<br />"; $embody .= "Attractions: $attractions1, $attractions2, $attractions3, $attractions4, $attractions5<br />"; $embody .= "Other Attractions Detail: $other_attractions"; $embody .= "</body></html>"; $header .= "Content-type: text/html\r\n"; mail( "jgravato82@gmail.com", "Custom Vacation Package Form", $embody, "From: $email", $header ); header( "Location: http://www.wdwvip.com/thankyou.htm" ); ?> Quote Link to comment Share on other sites More sharing options...
rondog Posted April 21, 2009 Share Posted April 21, 2009 your From: $email is part of the header..combine those two mail(email,subject,message,headers) Quote Link to comment 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.