1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Simple php contact form

Discussion in 'PHP' started by Imigras, Oct 5, 2008.

  1. #1
    Hi, i looking for a simple contact form, something like this:

    Name:
    E-mail:
    Message:

    after the client click on the "send" button i receive a e-mail with the name/e-mail/message :)
     
    Imigras, Oct 5, 2008 IP
  2. amazingronit

    amazingronit Well-Known Member

    Messages:
    1,334
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    130
    #2
    i have one . let me know your email, i'll send you the codes. hope you have sendmail in your server
     
    amazingronit, Oct 5, 2008 IP
  3. mehdi

    mehdi Peon

    Messages:
    258
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Make a new file in PHP , maybe contact.php and Paste this:
    
    <?php
    if ($_POST){
    $to      = "[B]youremail@gmail.com[/B]";
    $subject = "[B]YOUR SUBJECT[/B]";
    $email = $_REQUEST["email"];
    $name = $_REQUEST["name"];
    $message = "Name: ".$name."\r\n". "Email: ".$email."\r\n". "Message: ".$_REQUEST["message"];
    
    
    $headers = "From: $email";
    mail($to, $subject, $message, $headers);
    echo "Thanks for submitting.";
    }else{
    ?>
    <html>
    <head>
    <title>Contact Us</title>
    <body>
    <form action='[B]contact.php[/B]' method='post'>
    <tr>
    <td>
    Your Name: <input type='text' name='name'><br>
    </td>
    <td>
    Your Email: <input type='text' name='email'><br>
    </td>
    <td>
    Message: <textarea name='message'></textarea><br>
    </td>
    </tr>
    <input type='submit' value='Send comments'>
    </form>
    </body>
    </html>
    <?php
    }
    ?>
    
    Code (markup):
    Don't Forget to change text above in Bold.
    Make sure your server contains PHP with MAIL function enabled.

    Thanks
     
    mehdi, Oct 5, 2008 IP
  4. Imigras

    Imigras Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    mehdi ty ty ty ty :p i just tested your script, i love it :D
     
    Imigras, Oct 5, 2008 IP
  5. mehdi

    mehdi Peon

    Messages:
    258
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you buddy, im glad you like it!
     
    mehdi, Oct 6, 2008 IP
  6. Omzy

    Omzy Peon

    Messages:
    249
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Question - what is the best way to prevent spam bots from submitting spam messages on a simple form like the above? I know I can use JavaScript validation but the spam bots are clever enough to get around that. I guess I would have to use server-side validation - what is the most effective method to use?
     
    Omzy, Oct 6, 2008 IP
  7. Agent_Dweeb

    Agent_Dweeb Peon

    Messages:
    5,607
    Likes Received:
    384
    Best Answers:
    0
    Trophy Points:
    0
    #7
    CAPTCHA of course ;)
     
    Agent_Dweeb, Oct 6, 2008 IP
    scubita likes this.
  8. Omzy

    Omzy Peon

    Messages:
    249
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Anything else?
     
    Omzy, Oct 6, 2008 IP
  9. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #9
    why not program a cookie around it that only lets the user send an e-mail from their computer around every 12 hours? or consider storing their IP in a database and the time the last email was sent... basically the same principle
     
    Grit., Oct 6, 2008 IP
  10. Sillysoft

    Sillysoft Active Member

    Messages:
    177
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #10
    Yeah you can turn off JS so your JS check wont work if that happens. Captcha is a good way to deter from spamming. Data wise make sure you clean it up, if the field shouldnt accept html code then strip it. If the entry is suppose to be a number only then make sure its just a number. I had to go through all this when they used the mcafee scanner to test for any vulnerabilities on the website.

    Also if you need more functionality with email form check out PHPMailer.
     
    Sillysoft, Oct 6, 2008 IP
  11. techcone

    techcone Banned

    Messages:
    206
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Captcha -> Best Method.
     
    techcone, Oct 6, 2008 IP
  12. adolix

    adolix Peon

    Messages:
    787
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #12
    You can make a simple form with ease using 123ContactForm web form maker service. Design your form there, put the HTML code on your website and once a visitor of yours fills that form, all that data will be delivered to your inbox.
     
    adolix, Nov 17, 2009 IP