亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php $_SESSION會員登錄實(shí)例分享

 更新時(shí)間:2021年01月19日 16:38:20   投稿:lijiao  
這篇文章主要為大家詳細(xì)介紹了php $_SESSION會員登錄實(shí)例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

php會員登錄模塊是網(wǎng)站開發(fā)中很簡單的一個(gè)模塊,本實(shí)例主要給php初學(xué)者一個(gè)簡單的參考,其中的邏輯還是要讀者自己領(lǐng)會,多編多思考。

login.php文件

<?php
 ob_start();
 session_start();
?>
<?
 // error_reporting(E_ALL);
 // ini_set("display_errors", 1);
?>
<html lang="en"> 
 <head>
  <title>Tutorialspoint.com</title>
  <link href="css/bootstrap.min.css" rel="stylesheet">  
  <style>
   body {
   padding-top: 40px;
   padding-bottom: 40px;
   background-color: #ADABAB;
   }   
   .form-signin {
   max-width: 330px;
   padding: 15px;
   margin: 0 auto;
   color: #017572;
   }   
   .form-signin .form-signin-heading,
   .form-signin .checkbox {
   margin-bottom: 10px;
   }   
   .form-signin .checkbox {
   font-weight: normal;
   }   
   .form-signin .form-control {
   position: relative;
   height: auto;
   -webkit-box-sizing: border-box;
   -moz-box-sizing: border-box;
   box-sizing: border-box;
   padding: 10px;
   font-size: 16px;
   }   
   .form-signin .form-control:focus {
   z-index: 2;
   }   
   .form-signin input[type="email"] {
   margin-bottom: -1px;
   border-bottom-right-radius: 0;
   border-bottom-left-radius: 0;
   border-color:#017572;
   }   
   .form-signin input[type="password"] {
   margin-bottom: 10px;
   border-top-left-radius: 0;
   border-top-right-radius: 0;
   border-color:#017572;
   }   
   h2{
   text-align: center;
   color: #017572;
   }
  </style>  
 </head> 
 <body>  
  <h2>Enter Username and Password</h2> 
  <div class="container form-signin">   
   <?php
   $msg = '';   
   if (isset($_POST['login']) && !empty($_POST['username']) && !empty($_POST['password'])) {    
    if ($_POST['username'] == 'tutorialspoint' && $_POST['password'] == '1234') {
     $_SESSION['valid'] = true;
     $_SESSION['timeout'] = time();
     $_SESSION['username'] = 'tutorialspoint';
     echo 'You have entered valid use name and password';
    }
    else 
    {
     $msg = 'Wrong username or password';
    }
   }
   ?>
  </div> <!-- /container -->  
  <div class="container">  
   <form class="form-signin" role="form" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
   <h4 class="form-signin-heading"><?php echo $msg; ?></h4>
   <input type="text" class="form-control" name="username" placeholder="username = tutorialspoint" required autofocus></br>
   <input type="password" class="form-control" name="password" placeholder="password = 1234" required>
   <button class="btn btn-lg btn-primary btn-block" type="submit" name="login">Login</button>
   </form>   
   Click here to clean <a href="logout.php" tite="Logout">Session.  
  </div>  
 </body>
</html>

Logout.php文件

<?php
 session_start();
 unset($_SESSION["username"]);
 unset($_SESSION["password"]); 
 echo 'You have cleaned session';
 header('Refresh: 2; URL=login.php');
?>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評論