//admin/user.action.php
<?php
header('Content-Type: text/html; charset=utf-8');
require_once ("global.php");
$act = $_POST ['act'];
if ($act=='add') {
if(empty($_POST['username'])){
exit("<script>alert('用户名不能为空!');window.history.go(-1)</script>");
}
if(empty($_POST['password'])){
exit("<script>alert('密码不能为空!');window.history.go(-1)</script>");
}
if($_POST['password']!=$_POST['password2']){
exit("<script>alert('两次密码输入不一致!');window.history.go(-1)</script>");
}
if(check_username($_SESSION['username'])){
exit("<script>alert('用户 ".$_POST['username']." 已经存在!');window.history.go(-1)</script>");
}
$record = array(
'username' =>$_POST ['username'],
'password' =>md5($_POST ['password']),
'userflag' =>$_POST ['userflag']
);
$id = $db->save('phpaadb_users',$record);
header("Location: user.php");
}
?>
<html>
<body>
<form action="/admin/user.action.php" method="post">
act: <input type="text" name="act" value="add" />
username: <input type="text" name="username" />
password: <input type="text" name="password" />
password2: <input type="text" name="password2" />
<input type="submit" />
</form>
</body>
</html>