login.php
实例
<?php if($_SERVER['REQUEST_METHOD'] == 'POST'){ //验证用户的邮箱和密码 require('inc/function.php'); //连接数据库 require('inc/connect.php'); //验证登录 list($check, $data) = check_login($dbc, $_POST['username'], $_POST['password']); //验证通过 if($check){ //设置cookie setcookie('id', $data['id']); setcookie('username', $data['user_name']); //跳转 redirect_user('loggedin.php'); }else{ $errors = $data; print_r($errors); } //关闭数据库 mysqli_close($dbc); } //加载:感觉是渲染模板 include ('login_page.php');
运行实例 »
点击 "运行实例" 按钮查看在线实例
logout.php
实例
<?php setcookie('id','',time()-3600); setcookie('username','',time()-3600); $page_title = '退出成功'; include('login_page.php');
运行实例 »
点击 "运行实例" 按钮查看在线实例