<?php require_once dirname(__FILE__) . '/include/UserSvc.php'; $uc = new UserSvc(); if ($_GET['act'] == 'logout') { $uc->logout(); } $errmsg = ''; if ($_POST) { $uname = trim($_POST['uname']); if (!preg_match('/^[0-9a-z_]+$/i', $uname)) { $errmsg = 'bad user name!'; } if (!$errmsg) { $uc->login($uname, ''); header('Location: ./'); die; } } include dirname(__FILE__) . '/header.php'; ?> <?php if ($errmsg) { ?> <div style="color: #f00;"> <?php echo $errmsg; ?> </div> <?php