Submiting form to email addy via PHP

Wynnefield

New Member
i was reading a php resource book at B&N last week or two, and it had some great examples of submitting a form to a .php page to route to an email address and display an echo message to the web visitor ...

any examples would be much appreciated ... thank you
 

Wynnefield

New Member
not much help from the site ... i found a book today with the perfect code snippets; however, after submitting the button on the contact.html page with <form action="contact.php" method="post"...>, i receive:

"parse error, unexpected T_STRING, expecting ']' .../contact.php on line 63"

the line referred to in the error is the $formsent = mail (...) line in the following code in contact.php:

<?php
/* receive and email form data from contact.html */
$name = $_POST['contact_name'];
$company = $_POST['contact_company'];
$email = $_POST['contact_email'];
$phone = $_POST['contact_phone'];
$subject = $_POST['contact_topic'];
$comments = $_POST['contact_comments];
$formsent = mail('[email protected]', $subject, $comments);
if ($formsent)
{echo "Thank you, $name. We have received your comments, and will respond with the next 48 hours.";}
else
(echo "We are currently experiencing problems with our contact form and apologize for any inconvenience. Please try again at your convenience.";)
?>

PLEASE HELP!! ... thank you (the winkie face is actually a ";" and ")" in the php code)
 

Chroder

New Member
Use bbcode to post code.

Anyway,
Code:
 else
(echo "We are currently experiencing problems with our contact form and apologize for any inconvenience. Please try again at your convenience.");

Is incorrect, replace with:

PHP:
else
{
    echo "We are currently experiencing problems with our contact form and apologize for any inconvenience. Please try again at your convenience.";
}
 

Chroder

New Member
Ah yes,

PHP:
 $comments = $_POST['contact_comments];

You are missing a quote.

PHP:
 $comments = $_POST['contact_comments'];
 

Wynnefield

New Member
oh my gosh! have you every looked at a piece of code for so long, you just can't see it right in front of your face???? ... thank you chroder

i owe ya one! ...
 

Wynnefield

New Member
i am surprised DW didn't catch it. the way i have been staring at my laptop during the last few weeks, it may have and i just didn't see the error ... anyway, thank you again. look for my new site in the review section later this week ... would love feedback from fellow designers ... wynne
 
Top