Jump to content

Need help formatting information from my form


jonnyroboto

Recommended Posts

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,

Link to comment
Share on other sites

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" );
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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" );
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.