:::

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

 


:::

書籍目錄

展開 | 闔起

http%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D28%26tbdsn%3D764

計數器

今天: 1300130013001300
昨天: 2138213821382138
總計: 7322582732258273225827322582732258273225827322582