My php contact form won't work. HELP!?

I've been trying this for a while now, following a few different online tutorials. It seems like a simple concept but i just cannot get the contact form to relay any data. I'll paste my php coding and my form below. Any help would be much appreciated. Thanks.
<div class="contact_form">
    <form id="contactform" action="contact.php" method="post">
  Name: <br><input name="name" type="text" id="name" value=""/>
    <br><br>
    Company Name: <br><input name="company_name" type="text" id="company_name" value=""/>
    <br><br>
    Telephone: <br><input name="telephone" type="tel" id="telephone" value=""/>
    <br><br>
    Email: <br><input name="email" type="email" id="email" value=""/>
    <br><br>
    Comments: <br><textarea name="comments" id="comments" value="" />  
    </textarea>
    <p></p>
    <input type="submit" name="submit" value="Send!"/>
</form> 
</div>
<?php
if (isset($_POST['name']) && isset ($_POST['company_name']) && isset ($_POST['telephone']) && isset ($_POST['email']) && isset ($_POST['coments']) ) {
  $name = $_POST['name'];
  $company_name = $_POST['company_name'];
  $telephone = $_POST['telephone'];
  $email = $_POST['email'];
  $comments = $_POST['comments'];
  if (!empty($name) && !empty($company_name) && !empty($telephone) && !empty($email) && !empty($comments) ) {
  $to = '[email protected]';
  $subject = 'Contact form submitted.';
  $body = $name. "\n" .$comments;
  $headers = 'From: ' .$email;
  if (@mail($to, $subject, $body, $headers)) {
  echo 'Thanks for contacting us. We\'ll be in touch soon!';
  } else {
  echo 'Sorry an error occurred. Please try again later.';
  } else {
  echo 'All fields are required.';
?>

Try this:
<!doctype html>
<html>
<?php
if ($_POST){
if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)){
$message="Please provide a correct email address";} else {
  $name = strip_tags($_POST['name']);
  $company_name = strip_tags($_POST['company_name']);
  $telephone = strip_tags($_POST['telephone']);
  $email = $_POST['email'];
  $comments = strip_tags($_POST['comments']);
  $to = '[email protected]';
  $subject = 'Contact form submitted.';
  $body = $name. "\n" .$comments;
  $headers = 'From: ' .$email;
  if (mail($to, $subject, $body, $headers)) {
  echo 'Thanks for contacting us. We\'ll be in touch soon!';
  } else {
  $message = 'Sorry an error occurred. Please try again later.';
?>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php echo "<p style='color:red'>$message</p>"; ?>
<div class="contact_form">
    <form id="contactform" action="contact.php" method="post">
<p>Name:<br/><input name="name" type="text" required /></p>
<p>Company Name: <br/><input name="company_name" type="text" required/></p>
<p>Telephone: <br/><input name="telephone" type="tel" required/></p>
<p>Email: <br/><input name="email" type="email" required/></p>
<p>Comments: <br/><textarea name="comments" required/>   </textarea></p>
    <input type="submit" name="submit" value="Send!"/>
</form>
</div>
</body>
</html>

Similar Messages

  • Grr. Cannot get PHP contact form to work.

    Hi!
    I cannot get a PHP contact form working. I have tried
    everything i can think of (which isn't much!) and can't get it to
    work. This is what i am using. Can anybody see what's wrong with
    this please? As you can see, the form contains a fromname,
    fromemail, subject and message fields.
    I'm a complete newb when it comes to PHP. Please please
    please help.

    Thanks for your reply.
    I just used the PHP provided in
    this
    tutorial?! Is the tutorial wrong?
    Sorry. As i said, i know nothing about PHP. How do i define
    the variables.

  • Need help with PHP contact form

    Hi guys,
    I've made a PHP contact form for my site and need help with a couple of things:
    The form action links an external PHP script (scripts/contact-form-script.php) but is there a way I can have it so the PHP script for the form is contained within the same PHP file as my contact form (contact.php)?
    I tried just putting the form code at the top of contact.php but the browser automatically reads the anti-spam re-direct, so maybe that needs revising too?
    The second thing is, how can I make the Name, Email and Message fields mandatory? So if a user tries to submit the form and hasn't filled in one of the required fields and clicks submit, contact.php reloads with a message at the top of the form saying something like 'Complete the required fields' and highlights the relevant field with a red border?
    Here's the code for contact.php:
    <form action="http://www.mydomain.com/scripts/contact-form-script.php" method="post" name="contact" id="contact">
    <p><strong>Name:*</strong><br />
    <input name="name" type="text" class="ctextField" /></p>
    <p><strong>E-mail:*</strong><br />
    <input name="email" type="text" class="ctextField" /></p>
    <p><strong>Telephone:</strong><br />
    <input name="telephone" type="text" class="ctextField" /></p>
    <p><strong>Company:</strong><br />
    <input name="company" type="text" class="ctextField" /></p>
    <p><strong>Address:</strong><br />
    <input name="address1" type="text" class="ctextField" /></p>
    <p><input name="address2" type="text" class="ctextField" /></p>
    <p><strong>Town:</strong><br />
    <input name="town" type="text" class="ctextField" /></p>
    <p><strong>County:</strong><br />
    <input name="county" type="text" class="ctextField" /></p>
    p><strong>Postcode:</strong><br />
    <input name="postcode" type="text" class="ctextField" /></p>
    <p><strong>Message:*</strong><br />
    <textarea name="message" cols="55" rows="8" class="ctextField"></textarea></p>
    <p><input name="submit" value="SEND MESSAGE" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
    </form>
    And this is the PHP I'm using to submit the form data for contact-form-script.php:
    <?php
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $to = "[email protected]";
    $subject = "Contact from website";
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
            $message= '
                <table cellspacing="0" cellpadding="8" border="0" width="500">
                <tr>
                    <td colspan="2"></td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td width="154" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td>
                  <td width="314" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$name.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>E-mail address:</strong></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$email.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Telephone number:</strong></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$telephone.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Company:</strong></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$company.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Address</strong></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$address1.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$address2.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Town</strong></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$town.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>County</strong></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$county.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Postcode</strong></td>
                  <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$postcode.'</td>
                </tr>
                <tr bgcolor="#eeeeee">
                    <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Message</strong></td>
                </tr>              
                <tr bgcolor="#eeeeee">
                    <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$message.'</td>
                </tr>              
                <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
             </table>
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mydomain.com/sent.php' ) ;
    ?>
    Any help on this would be greatly appreciated.
    Thank you and I hope to hear from you!
    SM

    Revised code with form validation for Name Email and Message:
    <?php
    if (array_key_exists('submit', $_POST)) {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $telephone = $_POST['telephone'];
        $company = $_POST['company'];
        $address1 = $_POST['address1'];
        $address2 = $_POST['address2'];
        $town = $_POST['town'];
        $county = $_POST['county'];
        $postcode = $_POST['postcode'];
        $formMessage = $_POST['message'];
    if (empty($name)) {
                                                $warning['name'] = "Please provide your name";
    if (empty($email)) {
                                                $warning['email'] = "Please provide your email";
    if (empty($formMessage)) {
                                                $warning['message'] = "Please provide your message";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $to = "[email protected]";
    $subject = "Contact from website";
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
            $message= "
    <table cellspacing='0' cellpadding='8' border='0' width='500'>
                <tr>
                    <td colspan='2'></td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td width='154' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Name</strong></td>
                  <td width='314' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$name."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>E-mail address:</strong></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$email."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Telephone number:</strong></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$telephone."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Company:</strong></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$company."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Address</strong></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$address1."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$address2."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Town</strong></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$town."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>County</strong></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$county."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Postcode</strong></td>
                  <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$postcode."</td>
                </tr>
                <tr bgcolor='#eeeeee'>
                    <td colspan='2' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Message</strong></td>
                </tr>              
                <tr bgcolor='#eeeeee'>
                    <td colspan='2' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$formMessage."</td>
                </tr>              
                <tr><td colspan='2' style='padding: 0px;'><img src='images/whitespace.gif' alt='' width='100%' height='1' /></td></tr>
             </table>
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    if (!isset($warning)) {
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mydomain.com/sent.php' ) ;
    ?>
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    p {
        margin: 0;
        padding: 10px 0 0 0;
    .warning {
        color:#C00;
    </style>
    </head>
    <body>
    <form action="" method="post" name="contact" id="contact">
    <p><strong>Name:*</strong><br />
    <input name="name" <?php if (isset($warning['name'])) { echo "style='border: 1px solid #C00'"; } ?> type="text" class="ctextField" />
    <?php if (isset($warning['name'])) { echo "<p class='warning'>".$warning['name']."</p>"; }?>
    </p>
    <p><strong>E-mail:*</strong><br />
    <input name="email" <?php if (isset($warning['email'])) { echo "style='border: 1px solid #C00'"; } ?>type="text" class="ctextField" />
    <?php if (isset($warning['name'])) { echo "<p class='warning'>".$warning['email']."</p>"; }?>
    </p>
    <p><strong>Telephone:</strong><br />
    <input name="telephone" type="text" class="ctextField" /></p>
    <p><strong>Company:</strong><br />
    <input name="company" type="text" class="ctextField" /></p>
    <p><strong>Address:</strong><br />
    <input name="address1" type="text" class="ctextField" /></p>
    <p><input name="address2" type="text" class="ctextField" /></p>
    <p><strong>Town:</strong><br />
    <input name="town" type="text" class="ctextField" /></p>
    <p><strong>County:</strong><br />
    <input name="county" type="text" class="ctextField" /></p>
    <p><strong>Postcode:</strong><br />
    <input name="postcode" type="text" class="ctextField" /></p>
    <p><strong>Message:*</strong><br />
    <?php if (isset($warning['message'])) { echo "<p class='warning'>".$warning['message']."</p>"; }?>
    <textarea name="message" <?php if (isset($warning['message'])) { echo "style='border: 1px solid #C00'"; } ?> cols="55" rows="8" class="ctextField"></textarea></p>
    <p><input name="submit" value="SEND MESSAGE" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
    </form>
    </body>
    </html>

  • Why some contact forms doesn't work on some websites? We don't receive the submission form with the information?

    Why some contact forms doesn't work on some websites? We don't receive the submission form with the information?

    Hi Aish
    I wanted to check the following, but the URL is not found, you have another one?
    thanks
    Nicole
        4. Visit http://my-site.com/scripts/form_check.php in a web browser and make sure you see all green checkmarks. If some items do not display green checkmarks that means that the hosting server is not configured correctly to allow the Form widgets to send email messages to the address you've specified.
                    Contact your web-hosting provider about the server configuration problem. Describe the items that are not marked as green in the form check page, so that they can help you set up the servers to use the correct settings.
    Il giorno 9-set-2014, alle ore 16:11, Aishvarya Raj Rastogi <[email protected]> ha scritto:
    Why some contact forms doesn't work on some websites? We don't receive the submission form with the information?
    created by Aishvarya Raj Rastogi in Help with using Adobe Muse CC - View the full discussion
    Hi Nicole,
    What is the "From" email address in your form?
    Also, have you checked the spam folder?
    Please check the following posts as well :
    https://forums.adobe.com/docs/DOC-3581
    Re: PHP mail may be disabled or incorrectly configured on the web server.
    Regards,
    Aish
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6714281#6714281
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Help with using Adobe Muse CC by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • Flash / PHP Contact Form

    Hello,
    I am setting up a flash site (well trying too)  and decided to get a Flash  template of Template Monster so I could work on it, I have the site up  and all but the contact form is not working properly. The problem is the Actionscript dosen't  seem to work with the contact.php file that came in the template pack and  when I contacted them it was of no help, I was just refered me to their help  pages which showed I just had to insert my email address after rec="??????" and it would work. The actionscript is;
    rec="[email protected]";
    serv="php";
    var fields_descriptions= Array ("",
    Array("t1", "your_name", "Your Name:"),
    Array("t2", "your_address", "Your Address:"),
    Array("t3", "phone", "Telephone:"),
    Array("t4", "message", "Message:"),
    Array("t5", "your_email", "E-mail:"),
    Array("t6", "field_3", "Address:"),
    Array("t7", "field_4", "fax:")
    function reset_txt(name,name2,value) {
    path=eval(_target);
    path[name2]=value;
    this[name].onSetFocus=function() {
    path=eval(_target);
    if(path[name2]==value) { path[name2]="";}
    this[name].onKillFocus=function() {
    path=eval(_target);
    if(path[name2]=="") { path[name2]=value;}
    for (i=1; i<=fields_descriptions.length; i++) {
    reset_txt("t"+i, fields_descriptions[i][1], fields_descriptions[i][2]);
    And the contact.php file has the following script;
    <?php
    $your_name = $_GET['your_name'];
    $your_address = $_GET['your_address'];
    $phone = $_GET['phone'];
    $your_email = $_GET['your_email'];
    $message = $_GET['message'];
    $headers .= 'Content-type: text/html; charset=iso-8859-1';
    $content = "<html><head><title>Contact letter</title></head><body><br>";
    $content .= "Company: <b>" . $your_company . "</b><br>";
    $content .= "Name: <b>" . $your_name . "</b><br>";
    $content .= "Phone: <b>" . $your_phone . "</b><br>";
    $content .= "E-mail: <b>" . $your_email . "</b><br><hr><br>";
    $content .= $your_message;
    $content .= "<br></body></html>";
    mail("[email protected]","New enquiry from website",$content,$headers);
    ?>
    <html>
    <body bgcolor="#282E2C">
    <div align="center" style="margin-top:80px;color:#FFFFFF;font-size:16px;font-family:Tahom a;font-weight:bold">
    Your message was sent to <br> East Coast Computer Services <br>We will be in contact with you soon. Thank you.
    </div>
    </body>
    </html>
    I do get email from the form in Outlook but the problem is it has no content just blank fields, see below:
    From: [email protected] [mailto:[email protected]]
    Sent: 24 March 2011 23:10
    To: [email protected]
    Subject: New enquiry from website
    Company:
    Name:
    Phone:
    E-mail:
    I  haven't got a breeze about Flash or PHP, I just know a small bit from  using Dreamweaver. Would you know what is preventing the form from  working, I know it something to do with Arrays but what do I change in the PHP file so I start to receive information in the contact form? Thank you in advance.
    Kevin

    kglad,
    The actionscript calls the PHP form but dosen't post any information, it loads in the browser and I get the email but nothing in it?
    I'm just looking for the correct Actionscript to paste into flash and hopefully get it working. Thanks for the help.

  • PHP contact form problems

    I've tried editing my contact form in a way that I could edit it. But, recently I've tried replacing the color behind my submit button. Instead the images I placed behind the text boxes end up being placed behind the submit button. If you could help me figure this out, that would be great Also if you have the chance, could you tell me how to get rid of the message area boxes' color and change it to transparent... and help me place an image behind it to replace the color. Thanks
    <?php
    //If the form is submitted
    if(isset($_POST['submit'])) {
    //Check to make sure that the name field is not empty
    if(trim($_POST['contactname']) == '') {
    $hasError = true;
    } else {
    $name = trim($_POST['contactname']);
    //Check to make sure that the subject field is not empty
    if(trim($_POST['subject']) == '') {
    $hasError = true;
    } else {
    $subject = trim($_POST['subject']);
    //Check to make sure sure that a valid email address is submitted
    if(trim($_POST['email']) == '') {
    $hasError = true;
    } else if (!eregi("^[A-Z0-9.%-]@[A-Z0-9.%-].[A-Z]{2,4}$", trim($_POST['email']))) {
    $hasError = true;
    } else {
    $email = trim($_POST['email']);
    //Check to make sure comments were entered
    if(trim($_POST['message']) == '') {
    $hasError = true;
    } else {
    if(function_exists('stripslashes')) {
    $comments = stripslashes(trim($_POST['message']));
    } else {
    $comments = trim($_POST['message']);
    //If there is no error, send the email
    if(!isset($hasError)) {
    $emailTo = '[email protected]'; //Put your own email address here
    $body = "Name: $name
    Email: $email
    Subject: $subject
    Comments:
    $comments";
    $headers = 'From: Barca Graphics Contact form <'.$emailTo.'>' . "
    " . 'Reply-To: ' . $email;
    mail($emailTo, $subject, $body, $headers);
    $emailSent = true;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>PHP Contact Form with JQuery Validation</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
    <script src="jquery.validate.pack.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#contactform").validate();
    </script>
    <style type="text/css">
    body {
    font-family:Arial, Tahoma, sans-serif ;
    #contact-wrapper {
    width:429px;
    border:;
    background:transparent ;
    padding:;
    #contact-wrapper div {
    clear:both;
    margin:1em 0;
    #contact-wrapper label {
    display:block;
    float:none;
    font-size:16px;
    width:auto;
    form#contactform input {
    background-color:transparent;;
    background-image:url('http://submitpage.webege.com/images/shapeimage_2.png');
    border-width:0px;
    padding:6px;
    padding-bottom:10px;
    font-size:16px;
    color:none;
    form#contactform textarea {
    font-family:Arial, Tahoma, Helvetica, sans-serif;
    font-size:100%;
    padding:0.6em 0.5em 0.7em;
    border-color:transparent;;
    border-style:transparent;
    border-width:1px;
    </style>
    </head>
    <body>
    <form method="post" action="<?php echo $SERVER['PHPSELF']; ?>" id="contactform">
    <label for="name"></label>
    <input type="text" size="50" name="contactname" id="contactname" value="Name" class="required"/>
    <label for="email"></label>
    <input type="text" size="50" name="email" id="email" value="Email" />
    <label for="subject"></label>
    <input type="text" size="50" name="subject" id="subject" value="Subject" />
    <label for="message"></label>
    <textarea rows="5" cols="50" name="message" id="message" class="required"></textarea>
    <input type="submit" value="Send" name="submit" />
    </form>
    <?php if(isset($hasError)) { //If errors are found ?>
    Please check if you've filled all the fields with valid information. Thank you.
    <?php } ?>
    <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
    Email Successfully Sent!
    Thank you <?php echo $name;?> for contacting Barca Graphics.
    <?php } ?>
    </body>
    </html>

    ereg() has been deprecated, it is recommended that you dont use it.
    You want to look at this
    http://www.php.net/manual/en/function.preg-match.php
    Within this page I found this:
    If you need to check for .com.br and .com.au and .uk and all the other crazy domain endings i found the following expression works well if you want to validate an email address. Its quite generous in what it will allow
    <?php
            $email_address = "phil.taylor@a_domain.tv";
         if (preg_match("/^[^@]*@[^@]*\.[^@]*$/", $email_address)) {
             return "E-mail address";        
    ?>

  • Problem with 'Reply-To' on PHP contact form...

    Hi guys,
    I've created a PHP contact form which works perfectly; except, when I receive the email to my inbox and go to reply to it, it doesn't reply to the email address of the person who submitted the form - in the reply field it appears to have the default server email address.
    Here's my code which I have included in the same PHP page as my form:
    <?php
    if (array_key_exists('submit', $_POST)) {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $formMessage = $_POST['message'];
    if (empty($name)) {
    $warning['name'] = "Please provide your name";
    if (empty($email)) {
    $warning['email'] = "Please provide your email address";
    if (empty($formMessage)) {
    $warning['message'] = "Please type your message";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $to = "[email protected]";
    $subject = "Enquiry from website";
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $message= "
    <table cellspacing='0' cellpadding='8' border='0' width='500'>
    <tr>
    <td colspan='2'></td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='154' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Name</strong></td>
    <td width='314' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$name."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>E-mail address:</strong></td>
    <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$email."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td colspan='2' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Message</strong></td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td colspan='2' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$formMessage."</td>
    </tr>
    <tr><td colspan='2' style='padding: 0px;'></td></tr>
    </table>
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    if (!isset($warning)) {
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mydomain.com/thankyou.php' ) ;
    ?>
    Can anyone see from my code why this would be happening?
    Thank you very much and hope to hear from you!
    SM

    Sorted!
    I removed...
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    ...and added...
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";

  • PHP Contact Form Problem

    Hi all,
    I'm trying to use a php Contact form and it's throwing up an error even before I click submit. As a newbie to PHP I don't really know where I am going wrong.
    Here's the link to the contact form.
    http://www.thesketchcollective.co.uk/clients/form-example/myform1.php
    Secondly, I would also like the form to send an email as well as send the info to CSV format. It currently just sends it to a CSV.
    Any help would be appreciated.
    Cheers
    Tom

    <?php
    if($_POST['formSubmit'] == "Submit")
    $errorMessage = "";
    if(empty($_POST['formMovie']))
    $errorMessage .= "<li>You forgot to enter a movie!</li>";
    if(empty($_POST['formName']))
    $errorMessage .= "<li>You forgot to enter a name!</li>";
    $varMovie = $_POST['formMovie'];
    $varName = $_POST['formName'];
    if(empty($errorMessage))
    $fs = fopen("mydata.csv","a");
    fwrite($fs,$varName . ", " . $varMovie . "\n");
    fclose($fs);
    header("Location: thankyou.html");
    exit;
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>My Form</title>
    </head>
    <body>
    <?php
    if(!empty($errorMessage))
    echo("<p>There was an error with your form:</p>\n");
    echo("<ul>" . $errorMessage . "</ul>\n");
    ?>
    <form action="myform1.php" method="post">
    <p>
    What is your favorite movie?<br>
    <input type="text" name="formMovie" maxlength="50" value="<?=$varMovie;?>" />
    </p>
    <p>
    What is your name?<br>
    <input type="text" name="formName" maxlength="50" value="<?=$varName;?>" />
    </p>
    <input type="submit" name="formSubmit" value="Submit" />
    </form>
    </body>
    </html>

  • My 'contact' form is not working.  When I send a test contact it returns to my adobe email account this: "Contact Form" has a new form submission.

    My 'contact' form is not working.  When I send a test contact it returns to my adobe email account this:
    "Contact Form" has a new form submission.

    What exactly is not working ? As you have mentioned form submission notification is received in your email account so form process is working I believe but you want the notifications to go to another email account I think.
    Have you added the email address in "Email to" field in form options ? If yes and then also you are not receiving the form , then please provide me the site url and post a screenshot or form with option box open.
    Thanks,
    Sanjit

  • Can anyone help with my PHP contact form please!

    Hi all,
    I've just implemented the email contact form as described in the PHP Solutions book by David Powers and it is working fine.
    What I'm having problems with is my form is at the bottom of a long page and you have to scroll or click a link to get to it, which means that when the submit button is pressed, whether the form is successfully submitted or a field hasn't been completed, the user ends up back at the top of the page having to scroll back down to the form before they can see the feedback (either thanking them for submitting or pointing out that they have tried to submit an incomplete form).
    Can anyone tell me how I can make the page redirect upon clicking submit so that the user returns to the part of the page where the form is so they can see the feedback instead of going to the top of the page where the form is out of view.
    Many thanks,
    Karl.

    I've attached the entire code from the page plus the css so you can see what's going on and in additiion I've put in the corefuncs.php include code.
    Hope that's enough, thanks for looking.
    Cheers,
    Karl.
    <?php
    include('includes/corefuncs.php');
    if (function_exists('nukeMagicQuotes')) {
    nukeMagicQuotes();
    // process the email
    if (array_key_exists('send', $_POST)) {
    $to = '[email protected]'; // use your own email address
    $subject = 'Feedback from my form page';
    // list expected fields
    $expected = array('name', 'email', 'comments');
    // set required fields
    $required = array('name', 'email', 'comments');
    // create empty array for any missing fields
    $missing = array();
    // assume that there is nothing suspect
    $suspect = false;
    // create a pattern to locate suspect phrases
    $pattern = '/Content-Type:|Bcc:|Cc:/i';
    // function to check for suspect phrases
    function isSuspect($val, $pattern, &$suspect) {
         // if the variable is an array, loop through each element
         // and pass it recursively back to the same function
         if (is_array($val)) {
              foreach ($val as $item) {
                   isSuspect($item, $pattern, $suspect);
         else {
         // if one of the suspect phrases is found, set Boolean to true
              if (preg_match($pattern, $val)) {
                   $suspect = true;
    // check the $_POST array and any subarrays for suspect content
    isSuspect($_POST, $pattern, $suspect);
    if ($suspect) {
    $mailSent = false;
    unset($missing);
    else {
    // process the $_POST variables
    foreach ($_POST as $key => $value) {
    // assign to temporary variable and strip whitespace if not an array
    $temp = is_array($value) ? $value : trim($value);
    // if empty and required, add to $missing array
    if (empty($temp) && in_array($key, $required)) {
    array_push($missing, $key);
    // otherwise, assign to a variable of the same name as $key
    elseif (in_array($key, $expected)) {
    ${$key} = $temp;
    // validate the email address
    if (!empty($email)) {
    // regex to ensure no illegal characters in email address
    $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
    // reject the email address if it doesn't match
    if (!preg_match($checkEmail, $email)) {
    array_push($missing, 'email');
    // go ahead only if not suspect and all required fields OK
    if (!$suspect && empty($missing)) {
    // build the message
    $message = "Name: $name\n\n";
    $message .= "Email: $email\n\n";
    $message .= "Comments: $comments";
    // limit line length to 70 characters
    $message = wordwrap($message, 70);
    // create additional headers
    $additionalHeaders = 'From: domain.com Feedback Form<[email protected]>';
    if (!empty($email)) {
    $additionalHeaders .= "\r\nReply-To: $email";
    // send it
    $mailSent = mail($to, $subject, $message, $additionalHeaders, '[email protected]');
    if ($mailSent) {
    // redirect the page with a fully qualified URL
    header('Location: http://www.domain.com/index.php#form-div');
    exit;
    ?>
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Page | title</title>
    <script type="text/javascript" src="jquery.min.js">></script>
    <script type="text/javascript" src="jquery.cycle.all.2.72.js"></script>
    <script type="text/javascript">
    $(function() {
        $('#slideshow').cycle({
            speed:       1400,
            timeout:     8000
    </script>
    <link href="main.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper" class="container">
    <div id="header">
    <h1 class="logo">XXX Xxxx Xxxxx</h1>
    <h2 class="subhead">Xxx Xxxxxxx xxx Xxxxxx Xxxxxxx xx Xxxx xxx Xxxxx.</h2>
    <div id="nav">
    <h2>Need more information?</h2>
    <h3>Look no further...</h3>
    <ul>
      <li><a class="nav-about" href="#about-div">About Us...</a></li>
      <li><a class="nav-contact" href="#contact-div">Contact Us...</a></li>
    </ul>
    </div>
    <!-- end nav -->
    </div><!-- end header -->
    <div id="page-content">
    <div id="cycle">
    <div id="cycle-nav"></div>
    <div id="slideshow" class="pics">
                <img src="im/slides/escape.jpg" border="0" alt="" title="" width="547" height="339" />
                <img src="im/slides/old-lady.jpg" border="0" alt="" title="" width="547" height="339" />
                <img src="im/slides/gouge.jpg" border="0" alt="" title="" width="547" height="339" />
                <img src="im/slides/disarm.jpg" border="0" alt="" title="" width="547" height="339" /></div><!-- slideshow -->
    </div><!-- cycle -->
    <div id="right-column">
    <div id="ladies">
    <h1>Xxxxxx xxx'x xxx xxxxx xxxx xxxx.</h1>
    <p>Xxxx xxxxxxxxx xxxx XXX xxxxx xxxxxxxxxx xxx xxxx xxxx xxxx xxxx!</p>
    <p class="bottom">XXXX XX xx xxxx xxx xxxx...</p>
    </div>
    <div id="courses">
         <div id="course1">
          <h2 class="top"><strong>Xxxx Xxxx Xxxxxxx Xxxxxx Xxxxxxx</strong></h2>
        <p>XXX Xxxx Xxxx Xxxxxxx xxxxxx xxx x xxxx-xxxx xxxxxxxx xxx xx xxxx xxxx xxxxx xxx xxxxxx.</p>
        <p><strong>XXXXX:</strong> XXX.XX xxx xxxxxx.</p>
        <p><strong>XXXX XXXXXX:</strong><br />
        Xxxxxx Xxx Xxxx<br /><strong>[XXXXXX XXXXXXXXX]</strong></p>
        <ul><strong>XXXXXX XXXXXXX:</strong>
    <li>Xxxxxx Xxx Xxxxxxxxx</li>
    <li>Xxxxxx Xxx Xxxxxxxx</li>
    <li>Xxxxxx Xx Xxxxxxx -XXXX</li>
    </ul>
        <h2>Xxxx Xxxxx...</h2>
        <p class="book-early">Xx xxxxx xxx xx xx xxxxxxxx xxxxxxx xxx xxx xxxxxxx xxx xxxxx xxxxxxxxxx xx x xxxxxxx xxxxxxx xxxxxxxx xx xxx xxxx xxx xxxxxxxxx xxxxxx xxxx xx xxxxx xx xxxxxxx xx xxx xxx xxxxxxxx xx xxxxxxxxx xx xxxxxx.</p>
        <h2><strong>Xxxxxxxxx xx xxx Xxxxxx</strong></h2>
        <p class="location">      XX. Xxxxxx Xxxx, <br />
          Xxx Xxxxxxxxx Xxxxxx, Xxxxxxxx Xxxx, Xxxx (xxxxx xxx xxxx xx xxxx).<br />
          Xxxxxxxx xx xxxxxxxxxxx xxxx xxxxxxxx Xxxx.</p>
        <h2><strong>Xxxxxxxxx xx xxx Xxxxxx</strong></h2>
        <p class="structure"><strong>Xxxxxxx xxxxxxx:</strong><br />
          XX.XXxx – XX.XX xx<br />
          <strong>Xxxxx xxxxx:</strong><br />
          XX xxxx.<br />
          Xxxxxx xxxxxxx xxxx xxx xxxxxx Xxxxx.<br />
          <strong>Xxxxxxxxxx xxxxxxx:</strong><br />XX.XXxx – X.XXxx</p>
        <h2><strong>Xxxxxx Xxxx...</strong></h2>
        <p class="news">Xxxxx xxxx xxxxx xxx xxxx xxxxx xxx Xxxx Xxxx Xxxxxxx Xxxxxx.<br />
        </p>
      </div>
      <div class="to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>
         <div id="course2">
          <h2 class="top"><strong>Xxxxx Xxxx Xxxxxxx Xxxxx Xxxxxxx</strong></h2>
          <p>Xxx XXX XXXXX Xxxx Xxxxxxx Xxxxx xxx x xxx-xxxx xxxxxxxx xxx xx xxxx xxxxxx.</p>
        <p><strong>XXXXX:</strong> XX.XX xxx xxxxxx</p>
        <p><strong>XXXX XXXXX:</strong><br /> 
        Xxxxxx XXxx Xxx<br /><strong>[XXXXXX XXXXXXX]</strong></p>
        <ul><strong>XXXXXX XXXXXXX:</strong>
    <li>Xxxxxx Xxx Xxxx</li>
    <li>Xxxxxx Xxx Xxxx</li>
    <li>Xxxxxx Xxx Xxxx</li>
    <li>Xxxxxx Xxx Xxxx</li>
    </ul>
        <h2>Xxxx Xxxxx...</h2>
        <p class="book-early">Xx xxxxx xxx xx xx xxxxxxx xxxxxxx xxx xxx xxxxxxx xxx xxxxx xxxxxxxxxx xx x xxxxxxxxx xxxxxxx xxxxxxxx xx xxx xxxx xxx xxxxxxxxx xxxxxx xxxx xx xxxxx xx xxxxxxx xx xxx xxx xxxxxxxxxx xx xxxxxxxxx x xxxxxx.</p>
        <h2><strong>Xxxxxxxxx xx xxx Xxxxx</strong></h2>
        <p class="location">Xxxxxxxxx Xxxx, Xxxxxx Xxxxxx, Xxxxx, (xxx xxxxxxx xxxxxxxxx xx -<br />
          Xxxxxxx xx xxxxxxxxxx xxxx - </p>
        <h2><strong>Xxxxs Xxxx...</strong></h2>
        <p class="news">Xxxxx xxxx xxxxx xxx xxxx xxxxx xxx Xxxxx Xxxx Xxxxxxx Xxxxx.<br />
        </p>
      </div><!-- Course 2 end -->
      <div class="to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>
    </div><!-- Courses end -->
    </div><!-- end right column -->
    <div id="main-content" >
    <div id="main-content-1" class="clearfix">
    <h2>Xxxxxxx xx xxx Xxxx Xxxxxxx<br />
    xxxxxxx xxxx xxx XXX.</h2>
    <h3>Xxxxxx xxx Xxxxx xxxxxxx…</h3>
    <p>Xxx XXX xx xx xxxxxxxxxxx xxxxx xxxxxx xxxxxxx xx xxxx xxxxxxx xx Xxxx xxx Xxxxx - Xxxx Xxxxxxxxx, xxxxxx xxxxxxxxx xx xxxxx xxxxxx xxx xxxxxx xxxxxx,   xxx xxxxxxxx x xxxx xxxxxxx xx xxxxxx xxxxxxxxx xx xxxxxxxx xxxx xxxxxxx.</p>
    <p>Xxx XXX xxxxxx xxx xxxxxxx xxx xxxxxxxx Xxxx Xxxxxxx xx xxx Xxxx / Xxxxx xxxx xx Xxxx Xxxxxxxxx.</p>
    <p>Xxx xxxxx xxxxxx xx x xxx xxx Xxxx Xxxxxxx Xxxxxx xxxx x xxxxxxxx xx xxxxxxxxx xxxx xxxxx xxxxx xx xxxx xx Xxxx xxxx xxxxx xxx xxxxxx xx xxx Xxxxxxxx Xxxxxx.</p>
    <p>Xxx xxxxxx xxxxxx xx x xxxxxx Xxxx Xxxxxxx Xxxxx xxxxx xx x xxx xxxx xxxxxxx xxx xx xxxx xx xxx xxxxxx xx xxxxx xx Xxxxxxxx Xxxx xx xxxxx Xxxxx Xxxxxx. Xxxxxxxx xxx xx xxxxx xx xxxx xxxxx.</p>
    <h3 class="extra-padding">Xxx xx xx xxx xxx xxxx xxxx xxx xxxxx?</h3>
    <p>Xxxx xxxxxx xx xxxxxxxxxx xxxxxx xx xxxxxx xxx xxx xxxx xxxxxx xxxxxxx xxx xxxx xxxxxx xx xx xxx xxxxxxxxxx xxx xxxx xx xxxx xx xx xxxxxxx xxxxxx xxxx xx xxxxxxxx xx xxxxxxxx xxxx xx xxxxxx xxxxxxxxxx xxxxxxx xxx xxxxxx xx xxxxx xxxxxxxx.</p>
    <p>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p><strong>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</strong></p>
    <p>xx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p>xx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p><strong>Xxxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx..</strong></p>
    <h3 class="extra-padding">Xxxxxxx xx…</h3>
    <h4>Xxx xxxxxxxxxx xx xxx Xxxx Xxxx Xxxxxxx Xxxxxx xxxxxxxx xxxx xxxxxx xxxx</h4>
    <h4>Xxx xxxxxxxxxx xx xxx Xxxx Xxxx Xxxxxxx Xxxxxx xxxxxxxx xxxx xxxxxx xxxx</h4>
    </div>
    <div id="main-content-2" class="clearfix">
      <h4> </h4>
    </div>
    </div><!-- end maincontent -->
    <div id="bottom-content">
    <div id="about-div">
    <h2>Xxxxx xx…</h2>
    <p>Xx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxx.</p>
    <p>Xx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxxXx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxx</p>
    <p>Xx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxx</p>
    <div class="about-bottom-to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>
    </div>
    <hr />
    <div id="links-div">
    <h2>Xxxxxx xxxxx...</h2>
    <ul>
         <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
    </ul>
    </div>
    <div id="contact-div">
    <h2>Xxxxxx xxx...</h2>
    <p>Xxxxx x xxxx xxx xxx xxxxxxxxxx xxx xxxxxxx x xxxx xxx xxx xxxxxxxxxx xxx xxx xxxx x xxxx xxx xxx xxxxxxxxxx xxx xxxxxxx x xxxx xxx xxx xxxxxxxxxx xxx xxx<br />
    </p>
    <p class="phone">Xxxxx</p>
    </div>
    <div id="form-div">
         <p>Please make sure you complete all three fields below so that we can reply directly.</p>
         <?php
              if ($_POST && isset($missing) && !empty($missing))
              ?>
              <p class="warning">Please complete the missing item(s) indicated.</p>
              <?php
              elseif ($_POST && !$mailSent) {
              ?>
              <p class="warning">Sorry, there was a problem sending your message.
              Please try later.</p>
              <?php
              elseif ($_POST && $mailSent) {
              ?>
              <p class="thanks"><strong>Your message has been sent. Thank you for your feedback.
              </strong></p>
              <?php } ?>
      <form method="post" id="feedback" class="contactForm" action="">
                                              <label for="name">Name: <?php
                                                 if (isset($missing) && in_array('name', $missing)) { ?>
                                                 <span class="warning">Please enter your name</span><?php } ?>
                                              </label>
                                     <input name="name" id="name" type="text" class="formbox"
                                             <?php if (isset($missing)) {
                                                      echo 'value="'.htmlentities($_POST['name']).'"';
                                             } ?>
                                             />
                                              <label for="email">Email: <?php
                                                 if (isset($missing) && in_array('email', $missing)) { ?>
                                                 <span class="warning">Please enter a valid email address</span><?php } ?>
                                            </label>
                                        <input name="email" id="email" type="text" class="formbox"
                                            <?php if (isset($missing)) {
                                                      echo 'value="'.htmlentities($_POST['email']).'"';
                                            } ?>
                                            />
                                        <label for="comments">Comments: <?php
                                            if (isset($missing) && in_array('comments', $missing)) { ?>
                                            <span class="warning">Please enter your comments</span><?php } ?>
                                            </label>
                                        <textarea name="comments" id="comments" cols="30" rows="10"><?php
                                                 if (isset($missing)) {
                                                      echo htmlentities($_POST['comments']);
                                            } ?></textarea>
                                             <input name="send" id="send" class="formSubmit" type="submit" value="Send message" />
      </form>
       <div class="form-bottom-to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>                         
    </div>
    </div>
    <div id="footer">
    <p>Xxxxxxxxxxxxx</p>
    </div>
    </div><!-- wrapper -->
    </div>
    <!-- end page-content -->
    </div><!-- end wrapper -->
    </body>
    </html>
    /* following is the include php code */
    <?php
    function nukeMagicQuotes() {
      if (get_magic_quotes_gpc()) {
        function stripslashes_deep($value) {
          $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
          return $value;
        $_POST = array_map('stripslashes_deep', $_POST);
        $_GET = array_map('stripslashes_deep', $_GET);
        $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    ?>
    /* Following is the css */
    @charset "UTF-8";
    /* CSS Document */
    html { margin: 0; background: #faf9f2 url(im/background_texture_tile.jpg) top center repeat; text-align: center; }
    body { margin: 0 auto; background: url(im/background_texture_tile.jpg) top center repeat; text-align: center; width: 910px;
    padding: 0; font: 62.5% Arial, Verdana, Helvetica, sans-serif; }
    h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, form, label, fieldset, legend, blockquote, table { margin: 0; padding: 0; }
    #wrapper {
         text-align: left;     
         position: relative;
    .container{     
         margin: 0 auto 0;
         width: 910px;
    #header {
         width: 870px;
         height: 150px;
         margin: 0 20px 20px 20px ;
         background: url(im/header-bg.gif) top left no-repeat;
    h1.logo {
         float: left;
         height: 130px;
         width: 315px;     
         margin: 0 0 0 50px;
         border: 0;
         outline: 0;
         text-indent:-9999px;
         background:url(im/logo.jpg) 0 10px no-repeat;
         display: inline;
    h2.subhead {
         font-weight: bold;
         font-size: 1.6em;
         line-height: 1.4em;
         color: #999;
         float: right;
         width: 135px;
         text-align: right;
         margin: 25px 320px 0 0;
         display: inline;
    #nav {
         position: absolute;
         top: 0px;
         right: 50px;
         width: 270px;
         height: 277px;
         background: url(im/nav-bg.png) top left no-repeat;
    #nav h2 {
         font-size: 1.6em;
         text-align: center;
         color: #4D98C5;
         margin-top: 35px;
    #nav h3 {
         font-size:2.2em ;
         text-align: center;
         color: #4D98C5;
         padding-bottom: 13px;
         margin: 0 40px 0;
         border-bottom: 4.5px dotted #999;
    #nav ul {list-style:none;}
    #nav li {
    list-style:none;
    font-size: 1.4em;
    font-weight: bold;
    margin: 0 40px 0 40px ;
    border-bottom: 4.5px dotted #999;
    #nav li a {
    text-align: left;
    background-image:url(im/CSSSprite.jpg);
    background-repeat:no-repeat;
    color: #4D98C5;
    text-decoration: none;
    line-height: 65px;
    margin: 10px 0 10px 0;
    #nav li a.nav-about {
    background-position: 105px -15px;
    padding: 20px 95px 20px 0;
    #nav li a.nav-about:hover,
    #nav li a.nav-about:active,
    #nav li a.nav-about:focus {
    background-position: 105px -102px;
    color: #814098;
    #nav li a.nav-contact {
    background-position: 105px -180px;
    padding: 20px 80px 20px 0;
    #nav li a.nav-contact:hover,
    #nav li a.nav-contact:active,
    #nav li a.nav-contact:focus {
    background-position: 105px -267px;
    color: #814098;
    /* Cycle styles */
    #cycle {
         float: left;
         margin-left: 20px;
         margin-bottom: 25px;
         width: 547px;
         height: 339px;
         clear: both;
    .pics { height: 339px; width: 547px; padding:0; margin:0; overflow: hidden; border: 1px solid #814098; }
    /* End cycle styles */
    /*///// RIGHT CONTENT ////*/
    #right-column {
         float: right;
         width: 260px;
         margin: 0 53px 0 0;
         display: inline;
    #ladies {
         width: 252px;
         height: 437px;
         background: url(im/pink-ladies.png) top left no-repeat !important ;
         background: url(im/pink-ladies.gif) top left no-repeat ;
         margin: 120px 0 0 6px;
    #ladies h1 {
         margin: 0px 30px 150px 20px;
         padding-top: 60px;
         font: bold 2em Georgia, "Times New Roman", Times, serif;
         text-align: center;
         color: #6A437E;
    #ladies p {
         margin: 0px 30px 15px 20px;
         font: normal 1.8em Georgia, "Times New Roman", Times, serif;
         text-align: center;
         line-height: 1.4em;
         color: #EF4358;
    #ladies p.bottom {
         margin: 0px 30px 0px 20px;
         font: bold 2.2em Helvetica, Arial, sans-serif;
         text-align: center;
         color: #6A437E;
    #courses{
         margin-top: 15px;
         margin-bottom: 18px;
    #courses h2 {
         letter-spacing: .07em;
    /*Hull Course */
    #course1 {
         margin: 0 0 5px 6px ;
         width:240px;
         background:url(im/rightnav.gif) bottom left no-repeat;
    #course1 h2.top {
         background:url(im/rightnaw.gif) top left no-repeat;
         margin:0;
         padding:15px;
         color:#FFFFFF;
         font-size:1.6em;
         line-height: 1.4em;
         font-weight: bold;
         text-transform:uppercase;
    #course1 h2 {
         font-size:1.6em;
         line-height: 1.4em;
         color:#FFFFFF;
         background-color:#814198;
         padding:15px;
         text-transform:uppercase;
    #course1 p {
         font-size:1.4em;
         line-height:1.4em;
         padding: 15px 15px 0 15px;
         margin:0;
    #course1 p a {
         text-decoration:underline;
         font-weight:bold;
         color: #9f1f63     
    #course1 p a:hover {
         color: #ec008c;
    #course1 ul {
         margin: 20px 0 20px 15px;
         font-size:1.4em;
         line-height: 1.6em;
         list-style: none;
    #course1 p.book-early {
         padding-bottom: 20px;
    #course1 p.location {
         padding-bottom: 30px;
    #course1 p.structure {
         padding-bottom: 30px;
    #course1 p.news {
         padding-bottom: 30px;
    #right-column .to-top {
         color: #000;
         text-align: right;
         padding-right: 27px;
         margin-bottom: 40px;
    #right-column .to-top a, a:link {
         color: #000;
         font-size: 1.3em;     
         text-decoration: none;
    #right-column .to-top a:hover {
         text-decoration: underline;
    #course2 {
         margin: 0 0 5px 6px ;
         width:240px;
         background:url(im/rightnav.gif) bottom left no-repeat;
    #course2 h2.top {
         background:url(im/rightnaw.gif) top left no-repeat;
         margin:0;
         padding:15px;
         color:#FFFFFF;
         font-size:1.6em;
         line-height: 1.4em;
         font-weight: bold;
         text-transform:uppercase;
    #course2 h2 {
         font-size:1.6em;
         line-height: 1.4em;
         color:#FFFFFF;
         background-color:#814198;
         padding:15px;
         text-transform:uppercase;
    #course2 p {
         font-size:1.4em;
         line-height:1.4em;
         padding: 15px 15px 0 15px;
         margin:0;
    #course2 p a {
         text-decoration:underline;
         font-weight:bold;
         color: #9f1f63     
    #course2 p a:hover {
         color: #ec008c;
    #course2 ul {
         margin: 20px 0 20px 15px;
         font-size:1.4em;
         line-height: 1.6em;
         list-style: none;
    #course2 p.book-early {
         padding-bottom: 20px;
    #course2 p.location {
         padding-bottom: 30px;
    #course2 p.news {
         padding-bottom: 30px;
    /*///// RIGHT CONTENT ////*/
    #main-content {
         margin: 0 360px 0 40px;
         padding: 0;
    #main-content-1 {
         width: 510px;
    #main-content-2 {
         width: 510px;
    #main-content p {
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size: 1.6em;
         line-height: 1.4em;
         padding-bottom: 1em;
         color: #666;
    #main-content h2{
         padding: 0 0 20px 0;
         margin: 0;
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size: 3em;
         color: #666;
    #main-content h3 {
         font-size: 2.3em;
         color: #666;
         font-weight: normal;
         padding-bottom: 0.8em;
    #main-content h3.extra-padding {
         padding-top: 0.8em;
         padding-bottom: 0.8em;
    #main-content h4 {
         font-size: 2em;
         font-weight: normal;
    #bottom-content {     
         background-color: #814098;
         clear: both;
         margin: 0 20px;
         width: 870px;
         float: left;
    #bottom-content h2 {
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size: 2.6em;
         letter-spacing: .05em;
         color: #FFF;
         font-style: normal;
         padding: 0 0 15px 0;
    #bottom-content p {
         color: #FFF;     
    #about-div {
         padding: 0 320px 30px 0;
         background: url(im/sheila.png) 560px 20px no-repeat !important;
         background: url(im/sheila.jpg) 560px 20px no-repeat ;
    #about-div h2 {
         padding: 20px 28px 15px 28px;
    #about-div p {
         padding: 0 28px 20px 28px;
         font-size: 1.5em;
         line-height: 1.4em;
    .about-bottom-to-top {
         position: relative;
         top: 65px;
         right: -320px;
         text-align: right;
         padding-right: 33px;
         font-size: .68em;     
    .about-bottom-to-top a, a:link {
         color: #FFF;
         text-decoration: none;
    .about-bottom-to-top a:hover {
         text-decoration: underline;
    hr {
           margin: 40px 28px 20px 28px;
           color: #C09FCB;
           border-top: 1px black solid;
    #links-div {
         margin: 0 15px 0px 28px;
         float: left;
         width: 254px;
    #links-div li {
         list-style: none;
         padding: 0 0;
    #links-div li a {
         font-size:1.5em;
         line-height: 1.5em;
         text-decoration: none;
         color: #FFF;
    #links-div li a:hover {
         text-decoration: underline;
    #contact-div {
         margin: 0 10px 0 0;
         width: 254px;
         float: left;
    #contact-div p {
         font-size: 1.5em;
         line-height: 1.4em;
    #contact-div p.phone {
         font-size: 2.2em;
         font-weight: bold;
         letter-spacing: .05em;
    /* CONTACT FORM */
    #form-div {
         margin: 0 28px 50px 0 ;
         float: right;
         width: 281px;
    #form-div .contactForm {
         padding:6px;
    #form-div .contactForm .formbox {
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size:1.2em;
         color:#333;
         width:261px;
         padding:5px 3px;
         margin:0 0 5px 0 ;
         border:1px solid #666;
         border-top-color:#000;
         background:#fff url(im/contact-input.gif) top repeat-x;
    #form-div .contactForm #comments {
         font-family: Helvetica, Arial, sans-serif;
         font-size:1.23em;
         color:#333;
         line-height: 1.5em;
         width:258px;
         padding: 5px 0.4em 0 0.4em ;
         margin: 0 0 10px 0 ;
         display:block;
         clear:both;
         border:1px solid #666;
         border-top-color:#000;
         background:#fff url(im/contact-textarea.gif) top repeat-x;
    .formSubmit {
         display:block;
         clear:both;
         width:110px;     
         height:25px;
         padding:0;
         border:none;
         background-color: #251149;
         text-align:center;
         font-size:1.2em;
         color:#fff;
         cursor:pointer;
    .formSubmit:hover {
         background-color: #E76F34;
    .form-bottom-to-top {
         text-align: right;
         padding-right: 33px;
         font-size: 0.68em;     
         margin-top: 40px;
    .form-bottom-to-top a, a:link {
         color: #FFF;
         text-decoration: none;
    .form-bottom-to-top a:hover {
         text-decoration: underline;
    /* David Powers styles */
    .warning {
        font-weight: bold;
         font-size: 1em;
        color: #FCCCB9;
         display: block;
    .thanks {
        font-weight: bold;
        color: #f00;
         margin-left: 3px;
    #form-div p {
        margin: 0 0 10px 8px ;
         font-size: 1.5em;
         line-height: 1.4em;
    label {
        font-weight: bold;
         font-size: 1.6em;
        color: #FFF;
        display: block;
    /* END CONTACT FORM */
    #footer {
         height: 10em;
         background-color: #FFF;
         margin: 0 20px;
         clear: both;
    #footer p {
         font-size: 1.4em;
         color: #666;
         padding: 40px 0 30px 120px;     
         background: url(im/footer-logo.gif) 50px 20px no-repeat ;
    .clearfix:after{ content:"."; display:block; height:0; clear:both; visibility:hidden; }
    .clearfix {display: inline-block;}
    /* Hide from IE Mac \*/
    .clearfix {display:block;}
    /* End hide from IE Mac */
    * html .clearfix{ height: 1px; }

  • Help with html / php contact form

    Hi guys I was hoping to get some help with a contact form on my website, to be honest I havent a clue about php but kind of okay with html thats why the php code is just a copy and paste from some website, just trying to marry it up with the html but getting errors.
    Hopfully one of you can see the problem.
    Error on Submitting:
    Notice: Undefined variable: name in \\nas44ent\Domains\g\gethinhayman.co.uk\user\htdocs\send_form_email.php on line 69
    Notice: Undefined variable: message in \\nas44ent\Domains\g\gethinhayman.co.uk\user\htdocs\send_form_email.php on line 75
    We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.
    The Name you entered does not appear to be valid.
    The Comments you entered do not appear to be valid.
    HTML Code:
    <section id="contact" class="four">
                                                                <div class="container">
                                                                          <header>
                                                                                    <h2>Contact</h2>
                                                                          </header>
                                                                          <form method="post" action="send_form_email.php">
                                                                                    <div class="row half">
                                                                                              <div class="6u"><input type="text" class="text" name="name" placeholder="Name" /></div>
                                                                                              <div class="6u"><input type="text" class="text" name="email" placeholder="Email" /></div>
                                                                                    </div>
                                                                                    <div class="row half">
                                                                                              <div class="12u">
                                                                                                        <textarea name="message" placeholder="Message"></textarea>
                                                                                              </div>
                                                                                    </div>
                                                                                    <div class="row">
                                                                                              <div class="12u">
                                                                                                        <a href="http://www.mywebsite.co.uk/email_form.php" class="button submit">Send Message</a>
                                                                                              </div>
                                                                                    </div>
                                                                          </form>
                                                                </div>
                                                      </section>
    php Code:
    <?php
    if(isset($_POST['email'])) {
        $email_to = "my email address";
        $email_subject = "Mail from Site";
        function died($error) {
            // your error code can go here
            echo "We are very sorry, but there were error(s) found with the form you submitted. ";
            echo "These errors appear below.<br /><br />";
            echo $error."<br /><br />";
            echo "Please go back and fix these errors.<br /><br />";
            die();
        // validation expected data exists
        if(!isset($_POST['name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['message'])) {
            died('We are sorry, but there appears to be a problem with the form you submitted.');      
        $first_name = $_POST['name']; // required
        $email_from = $_POST['email']; // required
        $comments = $_POST['message']; // required
        $error_message = "";
        $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!preg_match($email_exp,$email_from)) {
        $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
        $string_exp = "/^[A-Za-z .'-]+$/";
      if(!preg_match($string_exp,$name)) {
        $error_message .= 'The Name you entered does not appear to be valid.<br />';
      if(strlen($message) < 1) {
        $error_message .= 'The Comments you entered do not appear to be valid.<br />';
      if(strlen($error_message) > 0) {
        died($error_message);
        $email_message = "Form details below.\n\n";
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        $email_message .= "Name: ".clean_string($name)."\n";;
        $email_message .= "Email: ".clean_string($email)."\n";
        $email_message .= "Message: ".clean_string($message)."\n";
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers); 
    ?>
    <?php
    ?>

    PHP CODE:  SaveAs send_form_email.php
    <?php
    if(isset($_POST['email'])) {
        // EDIT THE 2 LINES BELOW AS REQUIRED
        $email_to = "[email protected]";
        $email_subject = "Your email subject line";
        function died($error) {
            // your error code can go here
            echo "We are very sorry, but there were error(s) found with the form you submitted. ";
            echo "These errors appear below.<br /><br />";
            echo $error."<br /><br />";
            echo "Please go back and fix these errors.<br /><br />";
            die();
        // validation expected data exists
        if(!isset($_POST['name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['message'])) {
            died('We are sorry, but there appears to be a problem with the form you submitted.');     
        $name = $_POST['name']; // required
        $email_from = $_POST['email']; // required
        $comments = $_POST['message']; // required
        $error_message = "";
        $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!preg_match($email_exp,$email_from)) {
        $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
        $string_exp = "/^[A-Za-z .'-]+$/";
      if(!preg_match($string_exp,$name)) {
        $error_message .= 'The Name you entered does not appear to be valid.<br />';
      if(strlen($message) < 2) {
        $error_message .= 'The message you entered does not appear to be valid.<br />';
      if(strlen($error_message) > 0) {
        died($error_message);
        $email_message = "Form details below.\n\n";
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        $email_message .= "Name: ".clean_string($name)."\n";
        $email_message .= "Email: ".clean_string($email_from)."\n";
        $email_message .= "Message: ".clean_string($message)."\n";
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers);
    ?>
    <!-- include your own success html here -->
    Thank you for contacting us. We will be in touch with you very soon.
    <?php
    ?>
    HTML Code -- save as html page.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Contact Form</title>
    </head>
    <body>
    <section id="contact" class="four">
    <div class="container">
    <header>
    <h2>Contact</h2>
    </header>
    <form method="post" action="send_form_email.php">
    <div class="row half"> <div class="6u">
    <input type="text" class="text" name="name" placeholder="Name" />
    </div>
    <div class="6u">
    <input type="text" class="text" name="email" placeholder="Email" />
    </div>
    </div>
    <div class="row half"> <div class="12u">
    <textarea name="message" placeholder="Message"></textarea>
    </div>
    </div>
    <div class="row">
    <div class="12u">
    <input type="submit" name="submit" value="Send">
    </div>
    </div>
    </form>
    </div>
    </section>
    </body>
    </html>
    Upload both to your Apache server to test.
    EDIT:  changed typo on Submit button -- valuse to value.
    Nancy O.

  • Help with JS form, PHP Contact Form....

    I originally posted this in another area, but had no luck...
    I'm having trouble with a template that I downloaded (from Template Monster). My contact form shows "submitted", but I get no email.  I will submit my coding below & see if someone can help... My JS.forms is in a "JS" sub-folder in the main directory and my index.html and MailHandler.php/ashx files are in the main directory.
    MailHandler.php --
    <?php
        $owner_email = $_POST["owner_email"];
        $headers = 'From:' . $_POST["email"];
        $subject = 'A message from your site visitor ' . $_POST["name"];
        $messageBody = "";
        if($_POST['name']!='nope'){
            $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
            $messageBody .= '<br>' . "\n";
        if($_POST['email']!='nope'){
            $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
            $messageBody .= '<br>' . "\n";
        }else{
            $headers = '';
        if($_POST['state']!='nope'){       
            $messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
            $messageBody .= '<br>' . "\n";
        if($_POST['phone']!='nope'){       
            $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
            $messageBody .= '<br>' . "\n";
        if($_POST['fax']!='nope'){       
            $messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
            $messageBody .= '<br>' . "\n";
        if($_POST['message']!='nope'){
            $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
        if($_POST["stripHTML"] == 'true'){
            $messageBody = strip_tags($messageBody);
        try{
            if(!mail($owner_email, $subject, $messageBody, $headers)){
                throw new Exception('mail failed');
            }else{
                echo 'mail sent';
        }catch(Exception $e){
            echo $e->getMessage() ."\n";
    ?>
    JS Form --
    //forms
    ;(function($){
        $.fn.forms=function(o){
            return this.each(function(){
                var th=$(this)
                    ,_=th.data('forms')||{
                        errorCl:'error',
                        emptyCl:'empty',
                        invalidCl:'invalid',
                        notRequiredCl:'notRequired',
                        successCl:'success',
                        successShow:'4000',
                        mailHandlerURL:'MailHandler.php',
                        ownerEmail:'I have Client's Email Here',
                        stripHTML:true,
                        smtpMailServer:'localhost',
                        targets:'input,textarea',
                        controls:'a[data-type=reset],a[data-type=submit]',
                        validate:true,
                        rx:{
                            ".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
                            ".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
                            ".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@(( ?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1 [0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][ 0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
                            ".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
                            ".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
                            ".message":{rx:/.{20}/,target:'textarea'}
                        preFu:function(){
                            _.labels.each(function(){
                                var label=$(this),
                                    inp=$(_.targets,this),
                                    defVal=inp.val(),
                                    trueVal=(function(){
                                                var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp [1]):inp.html()
                                                return defVal==''?defVal:tmp
                                trueVal!=defVal
                                    &&inp.val(defVal=trueVal||defVal)
                                label.data({defVal:defVal})                               
                                inp
                                    .bind('focus',function(){
                                        inp.val()==defVal
                                            &&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl))
                                    .bind('blur',function(){
                                        _.validateFu(label)
                                        if(_.isEmpty(label))
                                            inp.val(defVal)
                                            ,_.hideErrorFu(label.removeClass(_.invalidCl))                                           
                                    .bind('keyup',function(){
                                        label.hasClass(_.invalidCl)
                                            &&_.validateFu(label)
                                label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide()
                            _.success=$('.'+_.successCl,_.form).hide()
                        isRequired:function(el){                           
                            return !el.hasClass(_.notRequiredCl)
                        isValid:function(el){                           
                            var ret=true
                            $.each(_.rx,function(k,d){
                                if(el.is(k))
                                    ret=d.rx.test(el.find(d.target).val())                                       
                            return ret                           
                        isEmpty:function(el){
                            var tmp
                            return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal')
                        validateFu:function(el){                           
                            el.each(function(){
                                var th=$(this)
                                    ,req=_.isRequired(th)
                                    ,empty=_.isEmpty(th)
                                    ,valid=_.isValid(th)                               
                                if(empty&&req)
                                    _.showEmptyFu(th.addClass(_.invalidCl))
                                else
                                    _.hideEmptyFu(th.removeClass(_.invalidCl))
                                if(!empty)
                                    if(valid)
                                        _.hideErrorFu(th.removeClass(_.invalidCl))
                                    else
                                        _.showErrorFu(th.addClass(_.invalidCl))                               
                        getValFromLabel:function(label){
                            var val=$('input,textarea',label).val()
                                ,defVal=label.data('defVal')                               
                            return label.length?val==defVal?'nope':val:'nope'
                        ,submitFu:function(){
                            _.validateFu(_.labels)                           
                            if(!_.form.has('.'+_.invalidCl).length)
                                $.ajax({
                                    type: "POST",
                                    url:_.mailHandlerURL,
                                    data:{
                                        name:_.getValFromLabel($('.name',_.form)),
                                        email:_.getValFromLabel($('.email',_.form)),
                                        phone:_.getValFromLabel($('.phone',_.form)),
                                        fax:_.getValFromLabel($('.fax',_.form)),
                                        state:_.getValFromLabel($('.state',_.form)),
                                        message:_.getValFromLabel($('.message',_.form)),
                                        owner_email:_.ownerEmail,
                                        stripHTML:_.stripHTML
                                    success: function(){
                                        _.showFu()
                        showFu:function(){
                            _.success.slideDown(function(){
                                setTimeout(function(){
                                    _.success.slideUp()
                                    _.form.trigger('reset')
                                },_.successShow)
                        controlsFu:function(){
                            $(_.controls,_.form).each(function(){
                                var th=$(this)
                                th
                                    .bind('click',function(){
                                        _.form.trigger(th.data('type'))
                                        return false
                        showErrorFu:function(label){
                            label.find('.'+_.errorCl).slideDown()
                        hideErrorFu:function(label){
                            label.find('.'+_.errorCl).slideUp()
                        showEmptyFu:function(label){
                            label.find('.'+_.emptyCl).slideDown()
                            _.hideErrorFu(label)
                        hideEmptyFu:function(label){
                            label.find('.'+_.emptyCl).slideUp()
                        init:function(){
                            _.form=_.me                       
                            _.labels=$('label',_.form)
                            _.preFu()
                            _.controlsFu()
                            _.form
                                .bind('submit',function(){
                                    if(_.validate)
                                        _.submitFu()
                                    else
                                        _.form[0].submit()
                                    return false
                                .bind('reset',function(){
                                    _.labels.removeClass(_.invalidCl)                                   
                                    _.labels.each(function(){
                                        var th=$(this)
                                        _.hideErrorFu(th)
                                        _.hideEmptyFu(th)
                            _.form.trigger('reset')
                _.me||_.init(_.me=th.data({forms:_}))
                typeof o=='object'
                    &&$.extend(_,o)
    })(jQuery)
    $(window).load(function() {   
        $('#ContactForm').forms({
            ownerEmail:'I Have Client's Email Here'
    Contact HTML --
    <form action="contact.php" method="post" id="ContactForm">
                                <div class="success"> Contact form submitted!<br>
                                  <strong>We will be in touch soon.</strong> </div>
                                <fieldset>
                                  <div class="wrapper">
                                    <span class="col1">Name:</span>
                                    <label class="name">
                                      <span class="bg"><input name="cf_name" type="text" class="input"></span>
                                      <span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span>
                                      </label>
                                    </div>
                                  <div class="wrapper">
                                    <span class="col1">Email:</span>
                                    <label class="email">
                                      <span class="bg"><input name="cf_email" type="text" class="input"></span>
                                      <span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span>
                                      </label>
                                    </div>
                                  <div class="wrapper">
                                    <span class="col1">Phone:</span>
                                    <label class="phone">
                                      <span class="bg"><input name="cf_phone" type="text" class="input"></span>
                                      <span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span>
                                      </label>
                                    </div>
                                  <div class="wrapper">
                                    <span class="col1">Message:</span>
                                    <label class="message">
                                      <span class="bg"><textarea name="cf_message" rows="1" cols="1"></textarea></span>
                                      <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
                                      </label>
                                    </div>
                                  <div class="btns"><a href="#" class="link1" data-type="submit">Send</a><a href="#" class="link1" data-type="reset">Clear</a></div>
                                  </fieldset>
                                </form>

    If Template Monster supplied you with this code, I think you should contact them about it.
    It's not how I would do things.
    Nancy O.

  • This one is for Nancy o contact form does not work for me. please help

    http://alpenawebdesigns.com/form1.html
    for css i have form1.css and for php i have vsi2.php
    when i submit the form i get a 404 error and requested url/form-to-email.php not  found
    i like the form and for the life in me i can not see the obvious
    thank you
    allen macfalda

    I changed the vsi2.php to form-to-email.php and it appears to work exceppt that it does not send a return email
    allen macfalda

  • Contact Form won't display input text

    Hi,
    I'm trying to create a flash contact form that sends the
    user's message on enter key. Therefore I need you to help me do
    this and also help me understand why my form isn't displaying right
    when I have a mask for it.
    To get a better picture of the problem
    here you can
    see how the form should look like and
    here you can
    see the same form, but with the mask

    I'm not sure I understand what you mean by "embed the fonts
    in each of the text fields"
    Please have a look at the .fla file:
    http://www.claudiudesign.org/test/sterg.fla
    (this fla has the mask; if you remove it you will be able to
    see the working contact form)
    It won't take you more than 1 min to understand what's up
    with it if your good at this.
    Thing is I'm behind the schedule with this and I have to
    solve the problem as soon as possible.
    Thank You

  • My contact form is not working.

    Here is my html code for my contact form which is located in Contact.htm :
    <form method="POST" action="contact.php">
    <p>Name:<br>
    <input type="text" name="Name:">
    <p>Company:<br>
    <input type="text" name="Company:">
    <p>Phone:<br>
    <input type="text" name="Phone:">
    <p>Email:<br>
    <input type="text" name="Email:">
    <p>Comments:<br>
      <textarea name="Comments:" cols="45" rows="5"></textarea>
    <p><input type="submit" name="submit" value="Submit">
    </form>
    Here is my code which is located in my php file contact.php :
    <?php
    mb_http_input("UTF-8");
    mb_http_output("UTF-8");
    $EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
    $EmailTo = "[email protected]";
    $Subject = "Web Contact Form";
    $Name: = Trim(stripslashes($_POST['Name:']));
    $Company: = Trim(stripslashes($_POST['Company:']));
    $Phone: = Trim(stripslashes($_POST['Phone:']));
    $Email: = Trim(stripslashes($_POST['Email:']));
    $Comments: = Trim(stripslashes($_POST['Comments:']));
    $validationOK=true;
    if (Trim($EmailFrom)=="") $validationOK=false;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    $Body = "";
    $Body .= "Name:: ";
    $Body .= $Name:;
    $Body .= "\n";
    $Body .= "Company:: ";
    $Body .= $Company:;
    $Body .= "\n";
    $Body .= "Phone:: ";
    $Body .= $Phone:;
    $Body .= "\n";
    $Body .= "Email:: ";
    $Body .= $Email:;
    $Body .= "\n";
    $Body .= "Comments:: ";
    $Body .= $Comments:;
    $Body .= "\n";
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    ?>
    The error I get when I submit the information on the form is:
    Parse error: syntax error, unexpected ':' in D:\Hosting\5199406\html\contact.php on line 8
    Line 8 = $Name: = Trim(stripslashes($_POST['Name:']));
    I actually took this line out to see if it would work and then it gave me an error that Line 9 was not working...
    HELP PLEASE!

    Hello,
    Please try to read this tutorial hoping it may help
    Creating a Contact form in Dreamweaver from scratch
    In this tutorial we will build a contact form with Dreamweaver CS3 from scratch, our application consists of 2 pages, The first page contains the contact form, and the second page contains the form submission action and the thank you message. Also we will use Dreamweaver form validation behavior to validate the form. The Validate Form behavior checks the contents of specified text fields to ensure that the user has entered the correct type of data.
    Best Regards
    Waleed Barakat
    Developer-Online Creator and programmer

Maybe you are looking for

  • How to disable single cell in table control.

    Hi my requirement is to disable single cell in the table control. Please let me know How to do this. If possible please provide good module pool examples. Harish

  • Photo Booth crashes on startup

    Photo Booth app has suddenly decided it doesn't want to run. App icon in dock does its thing with pulsing dot, but application never opens and eventually I get the message "Photo Booth quit unexpectedly". I tried replacing the app with another (worki

  • Has Anyone Repaired "The Whine"?

    Has anyone sent in their computer to get the electronic whine fixed? If so, have they gotten it back, and did it work? I have the whine problem and was seeing if it is worthwhile. My MBP is my only computer, and I need it for school, so it would be h

  • Ad Hoc question on time

    If I create an ad hoc distribution version of my application, will it work forever, or is it limited to the amount of time that I am a registered developer? (or some other time limit)?

  • Problems with PC Suite and bluetooth connection to...

    Hi, I have the following: Pentium 4 PC running Windows XP service pack 2 PC Suite 6.82.22.0 PC Connectivity Solution: Version 6.43.9.0 Bluetooth stack: Microsoft Bluetooth stack Version 5.1.2600 Build 2180 I have had repeated problems trying to get a