Blogger Information
Blog 44
fans 0
comment 1
visits 30822
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
4月20日作业——cookile
时光记忆的博客
Original
596 people have browsed it

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');

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post