php form security help

Discussion in 'PHP' started by Funk-woo10, Sep 26, 2008.

  1. #1
    Hi,

    im just checking, when making a contact form on my site, what security measures are best to place ?

    This is a basic process form code -

    
    
    <?PHP
    
    
    $to="admin@site.com";
    $subject="Subject here";
    $message="This is the message";
    $headers= "From: site@site.com\r\n";
    $headers .= "Reply-To: site@site.com\r\n";
    
    
    if(mail($to, $subject, $message, $headers))
    
    {
    
    echo("Email sent");
    
    }
    
    else
    
    {
    
    echo("BAd luck");
    }
    
    ?>
    
    
    PHP:

    To stop spammers what is best practice.
     
    Funk-woo10, Sep 26, 2008 IP
  2. fireflyproject

    fireflyproject Active Member

    Messages:
    969
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    70
    #2
    What sort of security are you looking for? If you don't want bots spamming you, I would recommend using a simple captcha system. You can create this on your own pretty easily by asking a question and requiring a specific answer or you could use a free captcha class that's out there.

    You don't really have to worry about any sort of injection as this isn't doing anything with a database, so spammers are about the only nuisance.
     
    fireflyproject, Sep 26, 2008 IP
  3. alhelalat

    alhelalat Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    alhelalat, Oct 1, 2008 IP
  4. spc

    spc Well-Known Member

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    125
    #4
    You can add a captcha or some random IQ questions (like: 3 multiplied by 4 is=?)

    I think captcha is the best way to protect web forms from spammers.
     
    spc, Oct 1, 2008 IP
  5. classic

    classic Peon

    Messages:
    96
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    classic, Oct 8, 2008 IP
  6. Cesay

    Cesay Peon

    Messages:
    121
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Cesay, Oct 8, 2008 IP