Can someone look at my code and figure out why I'm not gettting emails?

I used several tutorials and did lots of reading on PHP, but I still can’t figure out what is wrong with my code. It redirects to the correct page but doesn’t send me an email that someone completed the form. can anyone help me figure it out?
Thanks

<?php /* Subject and Email Variables */ $emailSubject = 'website inquiry'; $webMaster = '[email protected]' /* Gathering Data Variables */ $nameField = $_POST['name']; $phoneField = $_POST['phone']; $emailField = $_POST['email']; $inquiringField = $_POST['inquiring about']; $commentsField = $_POST['comments']; $body = <<<EOD


Name: $name
Phone: $phone
Email: $email
Inquiring About: $inquiring
Comments: $comments
EOD; $headers = "From: $email\r\n\; $headers .= "Content-type: text/html\r\n\; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD HSH thank you page
Thank you for your interest! Your email will be answered very soon!
EOD; echo "theResults"; ?>

[php] $webMaster = ‘[email protected]’;[/php]

was missing a semicolon :stuck_out_tongue:

Hi,

I’m a newbie, too. I looked at your code as a learning exercise. There are many errors beyond the lack of a semicolon after your email address. You have multiple syntax errors and variable mismatches. I don’t understand the inclusion of ‘Field’ when declaring variables but it creates a mismatch when you later use the variable without including field.

I assume that you have a form to send the variables to your script. Since I didn’t have the form, I assigned values to the variables which you will not need to do when you use your form.

One thing that I do - remember I’m a newbie, too - is to use a lot of echo statements to make sure the script is actually doing what I want it to do.

I removed a few bits that I thought were surplussage.

This works on my local XAMPP, remember to remove the “//” before $success when you’re ready to start sending emails.
This is what I changed:
[php]

<?php /* Subject and Email Variables */ $emailSubject = 'website inquiry'; $webMaster = '[email protected]' ; // missing semicolon, as noted by darkfreaks /* Gathering Data Variables */ // /* Field */ causes a variable mismatch $name /* Field */ = $_POST['name'] = "post_name"; // remove assigned value after testing $phone /* Field */ = $_POST['phone'] = "post_phone"; // remove assigned value after testing $email /* Field */ = $_POST['email'] = "post_email"; // remove assigned value after testing $inquiring /* Field */ = $_POST['inquiring about'] = "post_inquiry"; // remove assigned value after testing $comments /* Field */ = $_POST['comments'] = "post_comments"; // remove assigned value after testing $body = "


Name: " . $name . "
Phone: " . $phone . "
Email: " . $email . "
Inquiring About: " . $inquiring . "
Comments: " . $comments . "


"; echo "BODY IS: " . $body . "
" ; // echo for debugging; remove or comment-out for final working version $headers = "From: $email\r\n\ "; $headers .= "Content-type: text/html\r\n\ "; // $success = mail($webMaster, $emailSubject, $body, $headers); // uncomment line when ready to actually send /* Results rendered as HTML */ $theResults = " HSH thank you page
Thank you for your interest! Your email will be answered very soon!
"; echo "
TheRESULTS:
". $theResults ; // variable - with $ sign - not in original script ?>

[/php]

Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service