New to forms. Validating a form which sends an email.

Discussion in 'Programming' started by pictureboarduk, Feb 23, 2009.

  1. #1
    Hi,

    I am creating a contactus form, which when submitted sends an email to the sites admin.

    As the form is not placing data into the database, but simply sending an email containing the submitted data to the admin's email, do I need to do any PHP validation? Or can I just use the client side JavaScript?

    If a hacker disables JavaScript, I'm worried that they may use it for malicious purposes.

    Thanks for any help!
     
    pictureboarduk, Feb 23, 2009 IP
  2. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    You should always do server validation, always. Never trust the client side.
     
    buldozerceto, Feb 23, 2009 IP
    pictureboarduk likes this.
  3. pictureboarduk

    pictureboarduk Well-Known Member

    Messages:
    551
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Thanks buldozerceto, +ve rep added, but am I thinking that the form data/email won't even enter the server, it will just be sent to the admin email address.

    Since none of the data will enter the database, why check it in the first place?

    *confused*
     
    pictureboarduk, Feb 23, 2009 IP
  4. pfek

    pfek Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #4
    You should validate server side, someone could use the form to span you so you might want to validate IP upon sending the mail.

    Use client side scripting to ameliorate your user's experience (like validating an empty field) but always protect your entries.
     
    pfek, Feb 23, 2009 IP