本篇內(nèi)容介紹了“如何實現(xiàn)php $_SESSION會員登錄”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
成都創(chuàng)新互聯(lián)公司專注于網(wǎng)站建設,為客戶提供成都網(wǎng)站設計、做網(wǎng)站、網(wǎng)頁設計開發(fā)服務,多年建網(wǎng)站服務經(jīng)驗,各類網(wǎng)站都可以開發(fā),成都品牌網(wǎng)站建設,公司官網(wǎng),公司展示網(wǎng)站,網(wǎng)站設計,建網(wǎng)站費用,建網(wǎng)站多少錢,價格優(yōu)惠,收費合理。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; } h3{ text-align: center; color: #017572; } </style> </head> <body> <h3>Enter Username and Password</h3> <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"> <h5 class="form-signin-heading"><?php echo $msg; ?></h5> <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'); ?>
“如何實現(xiàn)php $_SESSION會員登錄”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
本文標題:如何實現(xiàn)php$_SESSION會員登錄-創(chuàng)新互聯(lián)
瀏覽路徑:http://newbst.com/article36/iojpg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供App設計、網(wǎng)站導航、網(wǎng)站建設、面包屑導航、動態(tài)網(wǎng)站、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)