免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2027 | 回复: 8
打印 上一主题 下一主题

关于html+php的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-04 19:26 |只看该作者 |倒序浏览
最近总是有人修改html内容在提交   比如 html  有价格    他们就用工具把价格修改成-1000  
有没有办法  检测  这些价格的 比如它把 html的价格改成了-1000   检测到-1000的话 就自动提示  非法数据

论坛徽章:
0
2 [报告]
发表于 2008-11-04 19:32 |只看该作者
不是很明白~

但是不是想这样?

<form name="form1" method="post" action="" id="formHidden" onSubmit="return check_form(this);">
<input name="price" type="text" id="price">价格
...
</form>

<script language=JavaScript type=text/javascript>
<!--
function check_form()
{
    if(document.form1.price.value=='-1000')
    {
        alert(" 检测到-1000 提示非法数据") ;
    }
}
//-->
</script>

论坛徽章:
0
3 [报告]
发表于 2008-11-04 19:38 |只看该作者
“最近总是有人修改html内容在提交” 你是说用户把你的html下载到本地,然后修改里面的价格后在本地提交?如果是这样的话你可以设置一下,禁止从其他网站提交表单到你自己的服务器上。
不知道楼主想表达什么意思

论坛徽章:
0
4 [报告]
发表于 2008-11-04 19:38 |只看该作者
大概是你呢种意思
<td><form id="form3" name="form3" method="post" action="">
                    <table cellspacing="2" cellpadding="0" width="215" align="center" border="0" class="table1">
                      <tbody>
                        <tr>
                          <td align="left"><table cellspacing="0" cellpadding="0" align="left" border="0">
                            <tbody>
                              <tr>
                                <td><img height="13" src="image/hot.gif" width="39" /></td>
                              </tr>
                              <tr>
                                <td><table height="100" cellspacing="1" cellpadding="0" width="100" align="center" bgcolor="#e4e4e4" border="0">
                                  <tbody>
                                    <tr>
                                      <td><img height="100" src="image/cw/3.gif" width="100" border="0" /></td>
                                    </tr>
                                  </tbody>
                                </table></td>
                              </tr>
                            </tbody>
                          </table></td>
                          <td align="left"><strong><font color="#9900FF">名字:</font> </strong>兔基斯<br />
                                    <strong><font color="#9900FF">性别:</font> </strong><font color="#0099CC"><b>男</b></font> <font color="#FF9933"><b>女</b></font> <br />
                                                                        <input type="hidden" name="itemid" value="4217">
                                    <select name="laba" size="1" onchange="changedate(span3,this.options[this.selectedIndex].value,1500)">
                                          
                                          <option value=3>30天</option>
                                          
                                        </select><input type="hidden" name="money" value="1500">
                                      <span id="span3">50000</span> GB<br />
                            <br />
                            +300经验/回合
                            <table cellspacing="1" cellpadding="0" width="115" align="center" border="0">
                              <tbody>
                                                                      <tr>
                                          <td><img src="image/btn_buy.gif" width="48" height="19"  style="cursor:hand;" onClick="tijiao(3,1)"></td>
                                          <td align="right"><img src="image/btn_pre.gif" width="48" height="19"  style="cursor:hand;" onClick="tijiao(3,2)"></td>



着是部分物品代码
如果他把<span id="span3">50000</span> GB<br />着句 修改成-50000 写进我数据库里的就是-5000了   我就是想能不能检测html里的价格  只要检测出现  -   号 就提示非法数据

论坛徽章:
0
5 [报告]
发表于 2008-11-04 19:39 |只看该作者
别人不是 把html  下载到本地的 而是直接  用ie恶搞迷  直接修改的html在提交

论坛徽章:
0
6 [报告]
发表于 2008-11-05 08:29 |只看该作者
那个没办法防的,要在程序里做严格的校验。

论坛徽章:
0
7 [报告]
发表于 2008-11-05 09:12 |只看该作者
最常规~简单的办法~就是在数据提交时~检测~各个 input参数是否按要求进入填写~

方法

<script language=JavaScript type=text/javascript>
<!--
function check_form()
{
    if(document.form1.price.value<0)  //即判断是否是负数
    {
        alert(" 检测到输入为负数~ 提示非法数据") ;
    }
}
//-->
</script>

举一反三~ 以上方法是普遍~实现~ 检测提交数据的方法

论坛徽章:
0
8 [报告]
发表于 2008-11-05 09:40 |只看该作者
版主大人。
lz貌似提的是本地提交的问题。。。。。
php在往数据库里写数据之前,按照规则滤一遍数据。

论坛徽章:
0
9 [报告]
发表于 2008-11-05 10:17 |只看该作者
那就检查每个字段再提交吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP