I need a good code for a contact form with spam protector

Discussion in 'HTML & Website Design' started by iMaCuLaTe, Nov 17, 2012.

  1. #1
    Hey guys, I was wondering if any of you had some good scripts for a simple contact form that looks good. I would like something like this.

    http://www.fbardiaphotography.com/contact.php

    I would also like a little spam protector if that's possible. Any suggestions?

    Any help is appreciated. Thank you in advance.
     
    iMaCuLaTe, Nov 17, 2012 IP
  2. iMaCuLaTe

    iMaCuLaTe Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    bump. please help
     
    iMaCuLaTe, Nov 18, 2012 IP
  3. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #3
    That contact form is horrible.

    Why not make one yourself? It's very simple to pass variables through a form something like:

    contact.php
    <form method="post" action="contactus.php">
    <label>Name</label> <input type="text" name="name"><br />
    <label>Email</label> <input type="text" name="email"><br /><br />
    <textarea name="message">Type your message here...</textarea>
    <input type="submit" value="Submit" name="submit">
    </form>
    HTML:
    contactus.php
    <?php
    
    //Post variables
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $ip = $_POST['ip'];
    
    //Send message to administrator
    $to = "yourname@yourdomain.com";
    $subject = "Website Contact Form";
    $message = "This email was generated from yourdomain.com. \n\n Name: $name \n\n Email Address: $email \n\n Message: \n $message \n\n Just in case I'm a **** I've kindly provided you with my IP address: $ip";
    $from = "$name";
    $headers = "From:" . $from;
    mail($to,$subject,$message,$headers);
    
    header('Location: contact.php?message=success');
    
    
    ?>
    PHP:
    And add your css to the form.

    As for spam protection, I did carry out some research on preventing spam and the general consensus was that spam protection could put off genuine users from using your contact form. This could be for a number of reasons, mathematics for example even 1+1, in this day in age you never know... they may not know! Typing a word, what if they're dyslexic?

    From the research I carried out, I found that simply displaying their IP address would be enough to put off most spammers and only use CAPTCHAS as a last resort such as if you are on a list for spammers to target your website.
     
    scottlpool2003, Nov 19, 2012 IP
  4. iMaCuLaTe

    iMaCuLaTe Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the help man. The reason I didn't make one myself is because I'm pretty new to all this stuff. But all I would have to do is copy this code and place it in my site where I want it to be?
     
    iMaCuLaTe, Nov 19, 2012 IP
  5. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #5
    Yes, just add your own CSS to it to give it a bit of style.
     
    scottlpool2003, Nov 22, 2012 IP
  6. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #6
    As far as spam protection, define "spam". If you mean what gets to your mailbox, use POPFile. You control spam on the receiving end.
     
    Rukbat, Nov 22, 2012 IP