TP引用样式表和js文件及验证码
生活随笔
收集整理的這篇文章主要介紹了
TP引用样式表和js文件及验证码
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
TP引用樣式表和js文件及驗(yàn)證碼
引入樣式表和js文件
<script src="__PUBLIC__/bootstrap/js/jquery-1.11.2.min.js"></script> <script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script> <link href="__PUBLIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"></link>?布局頁(yè)面
<form action="__ACTION__" method="post"> <div class="panel panel-primary"><div class="panel-heading" style="text-align:center;"><h3 class="panel-title">登錄頁(yè)面</h3></div><div class="panel-body"><label class="col-sm-2 control-label yhm" id="yhm1">用戶名:</label><input type="text" class="form-control yhm" placeholder="請(qǐng)輸入用戶名" name="uid"> <label class="col-sm-2 control-label yhm" id="mm1">密碼:</label><input type="password" class="form-control yhm" placeholder="請(qǐng)輸入密碼" name="pwd"> <label class="col-sm-2 control-label yhm" id="yzm1">驗(yàn)證碼:</label><input type="text" class="form-control yhm" placeholder="請(qǐng)輸入驗(yàn)證碼" name="yzm"><div style="height:10px;"></div><img id="yzm" src="__CONTROLLER__/yzm" /></div><div class="panel-body" style="text-align:center;"><button type="submit" class="btn btn-primary btn-sm">點(diǎn)擊登錄</button> </div></div>?js文件點(diǎn)擊刷新驗(yàn)證碼
<script type="text/javascript"> $("#yzm").click(function(){var s = Math.ceil(Math.random()*100);//隨機(jī)生成0-100的整數(shù)$(this).attr("src","__CONTROLLER__/yzm/a/"+s); }) $("#s").blur(function(){var s = $(this).val();$.ajax({url:"__CONTROLLER__/check",data:{s:s},type:"POST",dataType:"TEXT",success:function(data){alert(data);}}) }) </script>?
?php文件
<?php namespace Home\Controller; use Think\Controller; class LoginController extends Controller{public function login(){if(empty($_POST)){$this->show();}else{//驗(yàn)證碼驗(yàn)證//$_POST["yzm"];$y = I("post.yzm");$v = new\Think\Verify();//獲取驗(yàn)證碼if($v->check($y)){//驗(yàn)證碼是否正確//驗(yàn)證用戶名密碼$uid = I("post.uid");$pwd = I("post.pwd");$db = D("Users");$arr = $db->find($uid);$mm = $arr["pwd"];if($mm==$pwd&&!empty($pwd)){session("uid",$uid);$this->success("登錄成功正在跳轉(zhuǎn)",U("Index/index"));}else{$this->error("用戶名或者密碼不正確!");}}else{$this->error("驗(yàn)證碼不正確!");}}}public function yzm(){$v = new\Think\Verify();//實(shí)例化驗(yàn)證碼類$v->entry();//引用獲取驗(yàn)證碼的方法}public function check($s){$v = new\Think\Verify();if($v->check($s)){$this->ajaxReturn("驗(yàn)證碼正確,請(qǐng)輸入用戶名和密碼!","eval");}else{$this->ajaxReturn("驗(yàn)證碼不正確!","eval");}} }?
?======
驗(yàn)證碼參數(shù)
public function yzm(){$v = new\Think\Verify();//實(shí)例化驗(yàn)證碼類//$v->useImgBg = true;//$v->fontSize = "100";//$v->lenth = 3$v->entry();//引用獲取驗(yàn)證碼的方法//如果好幾個(gè)驗(yàn)證碼 可以用id區(qū)分//$v->entry(1);//然后check()方法后面多一個(gè)id參數(shù)如check($s,1)}?可以在這里修改驗(yàn)證碼的內(nèi)容---------
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/navyouth/p/8594194.html
總結(jié)
以上是生活随笔為你收集整理的TP引用样式表和js文件及验证码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 梦到头发掉了好多什么意思
- 下一篇: Exchange 2016部署实施案例篇