html5_手机web开发

手机屏幕上的网页宽度适配


<meta http-equiv="content-type" content="text/html; charset=utf-8" />


<meta name="viewport" content="initial-scale=1, user-scalable=0, minimal-ui">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=yes" />     
<meta name="apple-mobile-web-app-capable" content="yes" />    
<meta name="format-detection" content="telephone=no" />   




页面反馈及效果


<!DOCTYPE html>
<html>
<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		
		
		


<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=yes" />     
<meta name="apple-mobile-web-app-capable" content="yes" />    
<meta name="format-detection" content="telephone=no" />   

		<style type="text/css">


div{
  margin-left:1px;
}
#submit{
	margin-left:2px;
}
</style>


<script type="text/javascript">
var isCommited = false;


function isNull( str ){
if ( str == "" ) return true;
var regu = "^[ ]+$";
var re = new RegExp(regu);
return re.test(str);
}



function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value==""||isNull(value))
    {alert(alerttxt);return false}
  else {
	

  	if(!isCommited){
	isCommited = true;
	return true;
	}else{
		alert('请勿重复提交');
		return false;
	}

  	
  }
  }
}

function validate_form(thisform)
{
	

with (thisform)
  {
  if (validate_required(content,"文物名称为必填项")==false)
    {content.focus();return false}
  }
}
</script>


		<head>
<body>


<form action="http://xxx.yyy/ci/feedback/insert" method="post" οnsubmit="return validate_form(this)" >
<input name="language" type="hidden" value="guobao">
<div id="big_1" style="clear:both;">
<div id="a" style="float:left; height:32px;width:32px"><img src="guobao_title.png" alt="" width = "32px" height = "32px"/></div>
<div id="b" style="float:left; height:32px;width:50%">


<input type="text" name="content" value="" placeholder="请输入要纠错的文物名称" style="width:100%;height:32px;" />

</div>
<div style="clear:both"></div><!--这个层很有用,必须要,否则可能不兼容。--> 
</div>

<div id="big_2" style="clear:both;height=10px;"> <br/> </div>

<div id="c" style="clear:both;">
<div id="a" style="float:left; height:32px;width:32px"><img src="guobao_phone.png" alt="" width = "32px" height = "32px"/></div>
<div id="b" style="float:left; height:32px;width:50%">

<input type="text" name="contact" value="" placeholder="请留下妳的联系方式(可空)" style="width:100%;height:32px;" />

</div>
<div style="clear:both"></div><!--这个层很有用,必须要,否则可能不兼容。--> 
</div>
<div id="d" style="clear:both;height=10px;"> <br/> </div>





<input id="submit_btn" name="submit" type="image" src="guobao_submit.png" alt="Submit" width="32px" height="32px">
</form> 



</body>
</html>



除js防重复提交外,数据库多列唯一索引防重复提交(ip,content,date)

ALTER TABLE sg_app_feedback ADD CONSTRAINT uc_contentipaddresspubdate UNIQUE (content,ipaddress,pubdate)


ALTER TABLE sg_app_feedback DROP INDEX uc_contentipaddresspubdate


date("Y-m-d")



使用ci框架的php代码


<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
header("Content-Type: text/html; charset=utf-8");
class Feedback extends CI_Controller {

    // 录入到where表格中,并且返回另一半的地址
    public function insert(){
        
        $language = $_POST["language"];
        $content = $_POST["content"];
        // 可空
        $contact = $_POST["contact"];
        $ipaddress = $_SERVER["REMOTE_ADDR"];
        $servername = $_SERVER['SERVER_NAME'];
        if ($servername != "xxx.yyy") {
            # code...
            echo "非法的访问";
            return;
        }
         // 时间戳
        $timeStamp = time();
        if (strlen($content) > 250 || strlen($contact) > 250 || strlen($language) > 250) {
            # code...
            echo "字数不得超过255";
            return;
        }
        if (strlen($content) == 0 || strlen($language) == 0) {
            # code...
            echo "妳还没有输入内容";
            return;
        }
        if (strlen($contact) == 0) {
            # code...
            $contact = "xxx.yyy";
        }

            // 成功则插入,返回ok
            // 插入 (REMOTE_ADDR)
        // 时间戳
        $pubtime = time();
        $pubdate = date("Y-m-d");
                $sql =
                'INSERT INTO sg_app_feedback(language,content,contact,pubtime,ipaddress,pubdate)
                VALUES(?,?,?,?,?,?)';
                
                // $sql = "SELECT * FROM some_table WHERE id = ? AND status = ? AND author = ?";
                
                $B = $this->db->query($sql, array($language,$content,$contact,$pubtime,$ipaddress,$pubdate));
                if ($B == 1) {
                    # code...
                    // 插入成功,返回ok
                    echo "<h1>ok</h1>";
                }

          
    }
     
}

/* End of file log.php */
/* Location: ./application/controllers/log.php */

























  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值