Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2008
    Location
    Detroit, MI
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post

    Javascript, PHP email to form, validation

    Alright,

    no jokes now.. I'm new to this stuff, completely. So my question is this.

    I'm working on our company website and we're running a survey that calls to action a PHP form to email script, what I want to do is validate the fields to make sure participants are filling them out and we're getting all the necessary information. I've tried javascript form validation but can not seem to get it to work. Do i need to validate with PHP, in the same .php file that we have our form to email script?

    Any help would be appreciated.

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts
    You can use either javascript or php validation. PHP validation may be a little more secure, since if you had javascript validation someone could manually send the GET or POST variables to get around the validation. Normal users definitely wouldn't know how to do this, but theres a chance that a spammer might. Also if you're using something like a CAPTCHA to put off spammers, PHP validation is a necessity.

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    JavaScript form validation only provides convenience for users, not security. This means that JavaScript should be used as an "enhancement", not as a requirement. So your form should not be dependent on JavaScript alone to perform your validation. Instead, whatever server-side language you use to process the form (PERL, ASP, PHP, etc.) should also perform the same validation. Otherwise, people will be able to bypass your validation simply by disabling JavaScript.

  • #4
    New Coder
    Join Date
    Jun 2008
    Location
    Detroit, MI
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well we run the script in PHP to email it after the form has been completed, so within that same script I can use another PHP script for validation? and it will run both of the requests? I'll try that.

    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •