Client-Side vs. Server-Side Scripts to Process Order [closed]

佐手、 提交于 2019-12-13 22:04:08

问题


I am designing a website to allow the user to pick the size of their pizza and the toppings they put on it. Based on these choices, I want to write scripts to: 1. calculate the cost for that pizza when the form is submitted 2. Process payment (validate Credit Cards, etc )

After reading countless articles, it appears obvious that I have to do all the payment processing server-side (php). For the form validaton which will determine which toppings and size the user picked and determine a price for that pizza, should I do that server side or is it better to do it client side (javascript) ? Thank you!


回答1:


It is probably best to do a little of both. If you do it client-side, the user will be able to alter the values using inline javascript, which is a security vulnerability. Javascript validation is much faster and more convenient than server-side validation. Best practice is do both.




回答2:


Client side is optional, it can save you doing round trips to the web server every time you want something done. Server side is not, well not unless you already have a free meal deal for hackers.



来源:https://stackoverflow.com/questions/18882148/client-side-vs-server-side-scripts-to-process-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!