尊龙凯时人生就是搏

ÔõôʹÓÃthinkphp¿ò¼ÜʵÏֵǼ¹¦Ð§

µÚÒ»²½£º½¨ÉèµÇ¼ҳÃæ

Òª×îÏÈ£¬±ØÐèÏȽ¨ÉèÒ»¸öµÇ¼ҳÃæ¡£¸ÃÒ³ÃæÐèÒªº¬ÓÐÓû§ºÍÃÜÂëÀ¸Î»£¬ÒÔ¼°¡°µÇ¼¡±°´Å¥¡£¹¹½¨Ò³Ãæʱ£¬Ó¦¸ÃʹÓÃHTMLºÍBootstrap£¬²¢ÔÚÊÓͼ·¾¶ÖоÙÐнç˵¡£ÒÔÏÂÊÇÒ»¸öʾÀý£º

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Login</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        <h3>Login</h3>
        <form class="form-horizontal" role="form" method="post" action="/login/check">
            <div class="form-group">
                <label class="control-label col-sm-2" for="username">Username:</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="username" placeholder="Enter username" name="username">
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2" for="password">Password:</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="password" placeholder="Enter password" name="password">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-default">Login</button>
                </div>
            </div>
        </form>
    </div>
</body>
</html>

µÇ¼ºó¸´ÖÆ

µÚ¶þ²½£º½¨Éè¿ØÖÆÆ÷Action

½¨ÉèÒ»¸ö¿ØÖÆÆ÷Action£¬ÓÃÓÚ´¦ÀíµÇ¼ÇëÇó¡£Óû§¿Éͨ¹ýÔÚ¸ÃActionÖÐÌṩÓû§ÃûºÍÃÜÂë¾ÙÐÐÑéÖ¤£¬ÒÔÅжÏÆäÊÇ·ñ±£´æÓÚϵͳÖС£µ±Óû§ÃûºÍÃÜÂëÓÐÓÃʱ£¬Ó¦½«Óû§ÐÅÏ¢´æ´¢ÓڻỰÖУ¬²¢½«Óû§Öض¨Ïòµ½Ó¦ÓóÌÐòÖ÷Ò³¡£ÒÔÏÂÊÇÒ»¸öʾÀýµÇ¼¼ì²éActionµÄ´úÂ룺

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

<?php
namespace app\index\controller;

use think\Controller;
use think\Session;

class Login extends Controller
{
    public function index()
    {
        return view();
    }

    public function check($username, $password)
    {
        // ÔÚ´Ë´¦Ê¹ÓÃÄúµÄÂß¼­À´¼ì²âÓû§ÊÇ·ñÓÐÓÃ
        if ($username == 'admin' && $password == 'password') {
            Session::set('username', $username);
            $this->redirect('/');
        } else {
            $this->error('Invalid username or password');
        }
    }
}

µÇ¼ºó¸´ÖÆ

µÚÈý²½£º½¨Éè·ÓÉ

×îºó£¬ÐèÔÚ·ÓÉÖн¨ÉèÒ»¸ö»á¼û¿ØÖÆÆ÷µÄ·¾¶£¬ÒÔ±ã¿ÉÒԴӵǼҳÃæŲÓÃËü¡£ÒÔÏÂÊÇÒ»¸öʾÀý·ÓɵÄÀý×Ó£º

<?php
use think\Route;

Route::rule('/', 'index/index');
Route::rule('/login', 'login/index');
Route::rule('/login/check', 'login/check');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬’/login’»á¼û·¾¶Í¨¹ýÖ¸ÏòLogin¿ØÖÆÆ÷µÄindexÒªÁìÀ´ÏÔʾµÇ¼ҳÃæ¡£ÇëÇóµÇ¼»áÓÉ Login ¿ØÖÆÆ÷µÄ check ÒªÁì´¦Àí£¬¸ÃÒªÁìµÄ·¾¶Îª ‘/login/check’¡£

ÒÔÉϾÍÊÇÔõôʹÓÃthinkphp¿ò¼ÜʵÏֵǼ¹¦Ð§µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ