Security for php form

Discussion in 'PHP' started by haradeep, May 23, 2009.

  1. #1
    I created one form for my site. I want to that form to be more secure. Can u please help me with its security.


    Link to my form http://www.manaclassifieds.co.cc

    I see some hackers are automatically posting through it.

    I didn't take any security measures.
     
    haradeep, May 23, 2009 IP
  2. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    implement a captcha. I can do it for you for $10+paypal fees. Just IM me.
     
    NatalicWolf, May 23, 2009 IP
  3. AdscendJeremy

    AdscendJeremy Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Escape your form inputs using mysql_real_escape_string
    Also you may also sanitize the inputs of special characters like HTML tags.
     
    AdscendJeremy, May 23, 2009 IP
  4. xxKillswitch

    xxKillswitch Peon

    Messages:
    331
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yea, if this is entering into a mysql database use mysql_real_escape_string on all post data. Before you output any data to the screen, use htmlspecialchars so that you aren't open to XSS attacks.

    A captcha would be very nice too, maybe try re-captcha. It's very simple to integrate into your site and should help protect against most bots.

    Lastly, a dirty old trick that I don't know if it still works, but add a hidden form field and make sure once data is posted that it is empty. Bots don't see forms the way we do, they just see the HTML and will fill out the field. You can also try setting a hidden form field to 1 and make sure that value remains set to 1.
     
    xxKillswitch, May 24, 2009 IP
  5. bozy12v

    bozy12v Active Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    It's good to use non-convetional names for your inputs (don't use mail, email, e-mail, address for your e-mail field)
     
    bozy12v, May 24, 2009 IP
  6. bozy12v

    bozy12v Active Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #6
    here's a Contact Form Generator with captcha security and form validation (medium security): Contact Form Generator
     
    bozy12v, May 24, 2009 IP
  7. ranacseruet

    ranacseruet Peon

    Messages:
    302
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    simply implement a captcha, that's all.
     
    ranacseruet, May 24, 2009 IP
  8. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #8
    Doesn't he need to validate and sanitize and all that? im new to php but was very recently reading about that regarding forms and email etc.

    Or would he already have that in place?
     
    pipes, May 24, 2009 IP
  9. AaliyahRoma

    AaliyahRoma Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Look at this free php contact form with captcha:
    cafewebmaster.com/node/178
     
    AaliyahRoma, May 24, 2009 IP