Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

jQuery or PHP

  • 01-11-2012 11:15PM
    #1
    Registered Users, Registered Users 2 Posts: 1,298 ✭✭✭


    Hey guys, what would you use to validate your forms?

    JQuery or php scripting?


Comments

  • Posts: 0 ✭✭✭ [Deleted User]


    Both. You definitely should not be doing it all locally or all on the server.


  • Registered Users, Registered Users 2 Posts: 1,298 ✭✭✭off.the.walls


    So how would I go about it, not to used to forms. Need to get it to gather all the data and forward it all in a mail too me so would I use jQuery to validate it and PHP to send it? or how would i go about it?

    Thanks


  • Registered Users, Registered Users 2 Posts: 2,103 ✭✭✭ectoraige


    Both, attaching greater importance to the php side. Validate *everything* on the server, never rely on the client to provide correct data. Validation on the client side should be done primarily to assist the user.


  • Registered Users, Registered Users 2 Posts: 586 ✭✭✭Aswerty


    Validating on the server side (PHP) is vital so you can ensure the data is as expected. Validating on the client side (javascript/jQuery) is pretty much standard these days but it not a necessity, if you don't do it any invalid input message will be slow to appear because a round trip from client to server has to occur. If javascript is turned off the client side validation won't work and this is why it can't be used as the only point of validation. Typical rule of thumb to follow is anything coming from the client side is potentialy harmful.

    With regards to client side validation you can use the excellent jQuery Validation plugin http://docs.jquery.com/Plugins/Validation.

    So validate on client, validate on server then send email from the server.


  • Registered Users, Registered Users 2 Posts: 26,449 ✭✭✭✭Creamy Goodness


    validate client side to convey to the user when something goes wrong.
    validate server side to keep your balls out of the blender (figuratively speaking)


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,657 ✭✭✭komodosp


    Definitely PHP but also Javascript for usability.

    PHP because it's possible to bypass the javascript validation, either with the browser or by not even visiting the page with the form. (You don't know how the form info got to you).

    Javascript wherever possible because PHP validation means that the user will have to wait for the page to reload to find out they've entered something wrong - which is very annoying.


Advertisement