User input validation, client-side or server-side? [PHP/JS]

后端 未结 6 676
失恋的感觉
失恋的感觉 2020-12-10 08:08

Is it better to validate user input before it\'s sent to the server with JS or server side with PHP? Or maybe it\'s worth doing both just to be on the safe side?

I\'

6条回答
  •  [愿得一人]
    2020-12-10 08:17

    Validation, ALWAYS server side. I can tamper with your form client-side and fill in crazy values and still get validated. I can't tamper with server-side scripts.

    So when checking client-side, you're just saving a little time 'talking' with the server. Never use it to validate your data for real.

提交回复
热议问题