:::

2-1 index.php

<?php
session_start();

require_once 'smarty/libs/Smarty.class.php';
//實體化
$smarty = new Smarty;
//三元運算式
$name    = isset($_SESSION['name']) ? htmlspecialchars($_SESSION['name'], ENT_QUOTES) : '訪客';
$group   = isset($_SESSION['group']) ? $_SESSION['group'] : '';
$op      = isset($_REQUEST['op']) ? htmlspecialchars($_REQUEST['op'], ENT_QUOTES) : '';
$content = '';

switch ($op) {
    case 'login':
        require_once "config.php";
        $name = isset($_POST['name']) ? $_POST['name'] : '';
        if ($admin_id == $name and $admin_pass == $_POST['pass']) {
            $_SESSION['group'] = "admin";
            $_SESSION['name']  = $name;
            $content           = "登入成功";
        } elseif ($user_id == $name and $user_pass == $_POST['pass']) {
            $_SESSION['group'] = "user";
            $_SESSION['name']  = $name;
            $content           = "登入成功";
        } else {
            $content = "登入失敗";
        }
        header("location: index.php");
        exit;

    case 'logout':
        unset($_SESSION['group']);
        unset($_SESSION['name']);
        header("location: index.php");
        exit;

    default:
        # code...
        break;
}

$smarty->assign('my_name', $name);
$smarty->assign('group', $group);
$smarty->assign('page_title', '活動報名系統');
$smarty->assign('content', $content);
$smarty->display('index.tpl');

 


:::

書籍目錄

展開 | 闔起

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D764%26tbsn%3D28

計數器

今天: 4600460046004600
昨天: 2489248924892489
總計: 8026582802658280265828026582802658280265828026582