?? useradd.php
字號:
<?php
session_start(); //使用session存儲用戶ID信息
//包含用戶管理菜單
include("UserManager.php");
//當(dāng)單擊“確定”時
if(isset($_POST["btnAdd"]))
{
//實例化用戶對象
require_once("UserClass.php");
$user=new User();
//判斷是否有相同的登錄名,如果有,返回
$user_id=-1;
if($user->IsValid($_POST["LoginName"],$_POST["Password"],$user_id))
{
echo "<script language='javascript'>";
echo " alert('已經(jīng)存在同名用戶!');";
echo " history.go(-1);";
echo "</script>";
return;
}
//獲取表單信息
$new_user_array=Array(
"LoginName"=>$_POST["LoginName"],
"Password"=>$_POST["Password"],
"RealName"=>$_POST["RealName"],
"Department"=>$_POST["Department"],
"Email"=>$_POST["Email"],
"RoleId"=>$_POST["RoleSelect"]
);
//利用用戶類的Add()方法添加新用戶
$user->Add($new_user_array);
//注冊ss_user_id Session
$user->InitDataByUserName($_POST["LoginName"],$_POST["Password"]);
$ss_user_id =$user->mBasicInforArray[0]->UserId;
session_register("ss_user_id");
//頁面重定位
echo "<script language='javascript'>";
echo " alert('用戶添加成功');";
echo " location='UserView.php';";
echo "</script>";
}
?>
<html>
<head>
<title>添加用戶</title>
</head>
<body>
<h1 align="center">添加新用戶</h1>
<table width="90%" border="1" align="center" bgcolor="#F0F0F0">
<form method="POST" name="frmAdd" action=<?php echo $_SERVER['PHP_SELF'];?>>
<tr>
<td align="center" colspan=2></td>
</tr>
<tr>
<td width="30%" height="29">登錄名:</td>
<td colspan="2" height="29" width="78%">
<input type="text" name="LoginName" size="40" >
</td>
</tr>
<tr>
<td width="30%" height="29">登錄口令:</td>
<td colspan="3" valign="middle" align="left">
<input type="password" name="Password">
</td>
</tr>
<tr>
<td width="30%" height="29">真實姓名:</td>
<td colspan="2" height="29" width="78%">
<input type="text" name="RealName" size="40">
</td>
</tr>
<tr>
<td width="30%" height="29">所在部門:</td>
<td colspan="2" height="29" width="78%">
<input type="text" name="Department" size="40">
</td>
</tr>
<tr>
<td width="30%" height="29">電子郵件:</td>
<td colspan="2" height="29" width="78%">
<input type="text" name="Email" size="40">
</td>
</tr>
<tr>
<td width="30%" height="29">用戶角色:</td>
<td colspan="2" height="29" width="78%">
<?php include("RoleSelect.php");?>
</td>
</tr>
<tr>
<td colspan="3" height="24">
<div align="center"><font color="#00FF00">
<input type="submit" name="btnAdd" value="確定">
<input type="reset" value="重 寫" name="cencel">
</font></div>
</td>
</tr>
</form>
</table>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -