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

后端 未结 6 684
失恋的感觉
失恋的感觉 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条回答
  •  旧时难觅i
    2020-12-10 08:42

    Do both.

    Client side gives the responsiveness users expect and server side protects your data.

    I'm sure PHP has some libraries that would help you much like what ASP.NET MVC does to provide a way of doing both in one step.

提交回复
热议问题