Jump to content

Contact form script...What am I mising here?


smit2685

Recommended Posts

Can anyone help me with my code? I just want the results emailed to me. I must not be understanding the "if" statement very well..

Any help would be greatly appreciated!!

 

This is the error I get when I try and use the form....

 

Parse error: syntax error, unexpected '{' in /home/dppiatsn/public_html/test/Certified_construction/contact_form_response.php on line 24

 

 

 

Here is my form:

 

<form action="contact_form_response.php" method="post" name="EstimateForm">

  <table width="520" border="0" cellspacing="5">

    <tr>

      <td width="103"><label for="name">

      Name:</label></td>

      <td width="383"><input name="name" type="text" id="name" size="22" /></td>

    </tr>

    <tr>

      <td width="103"><label for="address">

      Address:</label></td>

      <td><input name="address" type="text" id="address" size="40" /></td>

    </tr>

    <tr>

      <td width="103"><label for="phone">

      Phone:</label></td>

      <td><input name="phone" type="text" id="phone" size="20" /></td>

    </tr>

    <tr>

      <td width="103"><label for="email">

      Email:</label></td>

      <td><input name="email" type="text" id="email" size="25" /></td>

    </tr>

    <tr>

      <td width="103"><label for="time">

      Best Time <br>to Contact:</label></td>

      <td><input type="text" name="time" id="time" /></td>

    </tr>

    <tr>

      <td width="103" height="127"><label for="comments">

      Comments:</label></td>

      <td><textarea name="comments" id="comments" cols="45" rows="8"></textarea></td>

    </tr>

    <tr>

      <td height="38"> </td>

      <td><label for=" submit "></label>

      <input type="submit" name=" submit " id=" submit " value="Submit" /></td>

    </tr>

  </table>

 

-----------------

 

Here is my script:

 

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

<title>

Contact Form Response

<title>

</head>

<body>

<?php

 

$name = $_POST['name'];

$address = $_POST['address'];

$phone = $_POST['phone'];

$email = $_POST['email'];

$time = $_POST['time'];

$comments = $_POST['comments'];

 

 

//validation

if(3 < strlen($name) && 3 <strlen($address) && 3 < strlen($phone) && 3 <strlen($email && 3 < strlen($time) && 3 < strlen($comments))

{

 

}

else

{

echo "You did not fill in the form properly. Please use the browswer's "back" button and update the form.";

 

}

 

$email_message = <<< EMAIL

Message from Website Form.

 

Name: $name

Address: $address

Phone: $phone

Email: $email

Best time to contact: $time

 

Message:

$comments

 

EMAIL;

 

 

if(mail('XxxxxXXXxxxXX','WebForm Email', $email_message))

{

echo "Your email has been delivered, we will contact you shortly.";

 

}

else

{

echo "We had a problem sending the email.";

}

 

 

 

?>

</body>

</html>

//validation  You were missing a ) in here
if(3 < strlen($name) && 3 <strlen($address) && 3 < strlen($phone) && 3 <strlen($email) && 3 < strlen($time) && 3 < strlen($comments))
{ NULL; }

else { // You forgot to \ your "
echo "You did not fill in the form properly. Please use the browser's \"back\" button and update the form.";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.