real_escape_string($_POST['name']); if (empty($name)) { die("姓名為必填!"); } $email = $db->real_escape_string($_POST['email']); if (empty($email)) { die("Eamil為必填!"); } $email = filter_var($email, FILTER_VALIDATE_EMAIL); if (!$email) { die("不合法的Email"); } $pass = $db->real_escape_string($_POST['pass']); if (empty($pass)) { die("密碼為必填!"); } $pass = password_hash($pass, PASSWORD_DEFAULT); $group = ($admin_id == $email) ? 'admin' : 'user'; $sql = "INSERT INTO `users` (`name`, `email`, `pass`, `group`) VALUES('{$name}', '{$email}','{$pass}','{$group}')"; $db->query($sql) or die($db->error); $uid = $db->insert_id; return $uid; } //結果送至樣板 $smarty->assign('my_name', $name); $smarty->assign('group', $group); $smarty->assign('page_title', '活動報名系統'); $smarty->assign('content', $content); $smarty->assign('op', $op); $smarty->display('index.tpl'); ```
進階搜尋