客户端与服务器端脚本处理订单 [英] Client-Side vs. Server-Side Scripts to Process Order

查看:86
本文介绍了客户端与服务器端脚本处理订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个网站,允许用户挑选他们披萨的大小和他们放在上面的配料。基于这些选择,我想写脚本到:
1.计算表单提交时的比萨饼成本
2.过程支付(验证信用卡等)

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 )

在阅读了无数篇文章之后,似乎很明显我必须完成所有支付处理服务器端(php)。对于表单validaton,它将确定用户选择哪些顶部和大小,并确定该比萨的价格,我应该做那个服务器端还是更好地做它的客户端(JavaScript)?谢谢!

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!

推荐答案

可能最好做两点。如果您是在客户端执行此操作,则用户将能够使用内联javascript来更改这些值,这是一个安全漏洞。 Javascript验证比服务器端验证快得多,也更方便。最佳做法是同时做到这一点。

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.

这篇关于客户端与服务器端脚本处理订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆