TP引用样式表和js文件及验证码
生活随笔
收集整理的這篇文章主要介紹了
TP引用样式表和js文件及验证码
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
TP引用樣式表和js文件及驗證碼
引入樣式表和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>?布局頁面
<form action="__ACTION__" method="post"> <div class="panel panel-primary"><div class="panel-heading" style="text-align:center;"><h3 class="panel-title">登錄頁面</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="請輸入用戶名" name="uid"> <label class="col-sm-2 control-label yhm" id="mm1">密碼:</label><input type="password" class="form-control yhm" placeholder="請輸入密碼" name="pwd"> <label class="col-sm-2 control-label yhm" id="yzm1">驗證碼:</label><input type="text" class="form-control yhm" placeholder="請輸入驗證碼" 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">點擊登錄</button> </div></div>?js文件點擊刷新驗證碼
<script type="text/javascript"> $("#yzm").click(function(){var s = Math.ceil(Math.random()*100);//隨機生成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{//驗證碼驗證//$_POST["yzm"];$y = I("post.yzm");$v = new\Think\Verify();//獲取驗證碼if($v->check($y)){//驗證碼是否正確//驗證用戶名密碼$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("驗證碼不正確!");}}}public function yzm(){$v = new\Think\Verify();//實例化驗證碼類$v->entry();//引用獲取驗證碼的方法}public function check($s){$v = new\Think\Verify();if($v->check($s)){$this->ajaxReturn("驗證碼正確,請輸入用戶名和密碼!","eval");}else{$this->ajaxReturn("驗證碼不正確!","eval");}} }?
?======
驗證碼參數(shù)
public function yzm(){$v = new\Think\Verify();//實例化驗證碼類//$v->useImgBg = true;//$v->fontSize = "100";//$v->lenth = 3$v->entry();//引用獲取驗證碼的方法//如果好幾個驗證碼 可以用id區(qū)分//$v->entry(1);//然后check()方法后面多一個id參數(shù)如check($s,1)}?可以在這里修改驗證碼的內(nèi)容---------
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/navyouth/p/8594194.html
總結
以上是生活随笔為你收集整理的TP引用样式表和js文件及验证码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到头发掉了好多什么意思
- 下一篇: Exchange 2016部署实施案例篇