? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ThinkPHP5.0簡單實現(xiàn)登錄
本人第一次學習PHP,先是學習了一下目前最流行的前端的框架Angular JS框架,然后就開始上手PHP的學習,之前我有過學習android十個月的基礎(chǔ),再就是零零散散的學習了一下html5+css,所以打算一邊實現(xiàn)某一個功能,就打算記錄下來,供自己更好的學習,歡迎大家指正。
首先看看前臺的代碼和效果:

再看看Script的代碼:
var app = angular.module('myApp', []);
app.controller('loginCtrl', function($scope, $http) {
$scope.login=function()
{
$http({
method: 'GET',
url: 'http://127.0.0.1/thinkphp_5.0_full/index.php/index/Index/getlogin?user='+$scope.name+'&password='+$scope.password+''
}).then(function successCallback(response) {
console.log(response.data)
location.href="first.html"
}, function errorCallback(response) {
// 請求失敗執(zhí)行代碼
console.log(response)
});
}
});
script的代碼里面就是使用了Angular js代碼的框架,login的登錄函數(shù),發(fā)起了http請求,請求參數(shù)類型get,url地址就是http:服務(wù)器/thinkphp/appliaction下的目錄/.PHP文件/具體方法/參數(shù)類型
控制器里面的代碼:
public function getlogin()
{
$user=input('get.user');
$password=input('get.password');
$result=Db::query("SELECT * FROM `user_tb` WHERE USER='$user' And PASSWORD='$password'");
if(!$result)
{
return 'no';
}
else
{
echo '登陸成功';
Db::table('user_tb')->where('USER',$user)->update(['CONDITION'=>'1']);
}
}
前提是必須鏈接數(shù)據(jù)庫