php $_SESSION会员登录实例
login.php文件 ? ?ob_start(); ? ?session_start(); ?> ? ?// error_reporting(E_ALL); ? ?// ini_set("display_errors",1); ?> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?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; ? ? ? ? ?} ? ? ? ? ? ?? ? ??? ? ? ? ?? ??? ? ? Enter Username and Password?? ? ? ? ? ? ? ? ? ? ? ? ? ? $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'; ? ? ? ? ? ? ? ?} ? ? ? ? ? ? } ? ? ? ? ??> ? ? ? ? ? ? ? ? ? ? ? ? ??? ??? ?? ? ? ? ?Click here to clean ? ? ? ? ? Logout.php文件 ? ?session_start(); ? ?unset($_SESSION["username"]); ? ?unset($_SESSION["password"]);? ? ?echo 'You have cleaned session'; ? ?header('Refresh: 2; URL=login.php'); ?> 演示图: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |