前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >网站---不要相信浏览器

网站---不要相信浏览器

作者头像
静心物语313
发布2020-03-24 14:45:57
7140
发布2020-03-24 14:45:57
举报

1、当提交的时候用。return checkForm() 这个方法。 2、服务器断的代码不可少,JavaScript 校验只是“可用性”考虑,而服务器端的校验才是正真的最后“把关者”。 3、服务器的代码如果少了,就会产生漏洞,js少了只是体验性不好而已! 4、在局网站中是没有办法获取主机的MAC地址的。http协议知道,所以不能用它来唯一标记。 5、只有在局域网中是可以获取主机的MAC地址的。 6、IP内网的公网的IP地址是一样的。

代码语言:javascript
复制
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>网银</title>
    <script type="text/javascript">
        function checkForm() {
            var amount = parseInt(document.getElementById("amount").value);
            if (amount>1000) {
                //alert("取款金额不能大于一千!");
               // return false;
            }
            return true;
        }
    </script>
</head>
<body>
    <form action="atm.ashx" method="post" οnsubmit="return checkForm();">
        取款金额:<input type="text" name="amount" id="amount" />
        <input type="submit" value="取款" />
    </form>
    
</body>
</html>

服务器端的验证必不可少:

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Web1.Day3.cp1
{
    /// <summary>
    /// atm 的摘要说明
    /// </summary>
    public class atm : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            //1、取得amount的对应的键值
            int amount = Convert.ToInt32(context.Request["amount"]);
            //2、服务器端的检查必不可少!!!
            if (amount>1000)
            {
                context.Response.Write("不能超过1000元!");
                return;
            }
            context.Response.Write("取款成功!");
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

如果服务器端没有设置验证: http://localhost:55725/Day3/cp1/atm.ashx?amount=9900 否则,懂程序的人就可以自己在地址栏中输入地址就可以直接达成目的!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档