Jump to content

Form Mailer Help Needed!


david101

Recommended Posts

I'd truly appreciate any help you can give me with the following PHP form mailer. I get the following error: Parse error: syntax error, unexpected T_ELSE in testcontact.php on line 31

Any ideas on how to fix the error?

 

Also, I need to sanitize the data, but I don't understand how to. Everything I've googled doesn't seem to work.

 

<?php

$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$mailinglist = $_POST['mailinglist'];
$companyname = $_POST['companyname'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$countrycode = $_POST['countrycode'];
$areacode = $_POST['areacode'];
$citycode = $_POST['citycode'];
$number = $_POST['number'];
$fcountrycode = $_POST['fcountrycode'];
$fareacode = $_POST['fareacode'];
$fcitycode = $_POST['fcitycode'];
$fnumber = $_POST['fnumber'];
$industry = $_POST['industry'];
$product = $_POST['product'];
$productnumber = $_POST['productnumber'];
$comments = $_POST['comments'];

if ($mailinglist != yes)
$mailinglist = no;


$mail_to = 'example@isp.com';  
$subject = 'Webform Data';  
$body = "First Name: $firstname \n Last Name: $lastname: \n Email: $email \n Mailing List: $mailinglist \n Company Name: $companyname \n Address: $address \n City: $city \n Zip: $zip \n Phone: $countrycode $areacode $citycode $number \n Fax: $fcountrycode $fareacode $fcitycode $fnumber \n Industry: $industry \n Product: $product \n Number of Packaged Products: $productnumber \n Comments/Questions: $commments ";

if (isset($_POST['Submit'])) {  
        mail($to, $subject, $body);
        echo "You will be contacted shortly."; 
        }; 
?>

<!DOCTYPE html PUBLIC "/W3C/DTD XHTML 1.0 Transitional/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="main.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Contact Us</title>
</head>
<form action="testcontact.php" method="post">* represents required field<br />
*First Name:<input name="firstname" type="text" maxlength="50" value="<?php echo $_POST['firstname']; ?>" /><br /> 
*Last Name:<input name="lastname" type="text" maxlength="50" value="<?php echo $_POST['lastname']; ?>" /><br /> 
*E-mail:<input name="email" type="text" maxlength="50" value="<?php echo $_POST['email']; ?>" /><br /> 
Join Mailing List(check if yes):<input name="mailinglist" type="checkbox" value="<?php echo $_POST['mailinglist']; ?>"/><br />
Company Name:<input name="companyname" type="text" maxlength="100" value="<?php echo $_POST['companyname']; ?>" /><br /> 
Address:<input name="address" type="text" maxlength="100" value="<?php echo $_POST['address']; ?>" /><br /> 
City:<input name="city" type="text" maxlength="100" value="<?php echo $_POST['city']; ?>" /><br /> 
Zip<input name="zip" type="text" maxlength="10" value="<?php echo $_POST['zip']; ?>" /><br /> 
Phone Number:<input name="countrycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['countrycode']; ?>" />-<input name="areacode" type="text" size="3" maxlength="3" value="<?php echo $_POST['areacode']; ?>" />-<input name="citycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['citycode']; ?>" />-<input name="number" type="text" size="4" maxlength="4" value="<?php echo $_POST['number']; ?>" /><br />
Fax:<input name="fcountrycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['fcountrycode']; ?>" />-<input name="fareacode" type="text" size="3" maxlength="3" value="<?php echo $_POST['fareacode']; ?>" />-<input name="fcitycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['fcitycode']; ?>" />-<input name="fnumber" type="text" size="4" maxlength="4" value="<?php echo $_POST['fnumber']; ?>" /><br /> 
Industry:<input name="industry" type="text" maxlength="50" value="<?php echo $_POST['industry']; ?>" /><br />
Product Packaged:<input name="product" type="text" maxlength="100" value="<?php echo $_POST['product']; ?>" /><br />
Number of Packaged Products:<input name="productnumber" type="text" maxlength="100" value="productnumber" /><br />
Comments/Questions:<br /><textarea name="comments" rows="5" cols="50" maxlength="10000"><?php echo $_POST['comments']; ?></textarea><br /> 
<input type="submit" value="submit" /> 
</form> 
</body>
</html>

 

 

 

 

Thanks!

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.