急!!!添加用户失败
King老师,注册用户为什么只讲了静态页面修改,实际的注册用户函数都没讲就完了啊,另外根据教程,将注册的函数拷贝到后台添加用户的admin.inc.php中,并跟着教程修改了,为什么添加用户老是失败,截图如下:

注册用户函数:
/**
* 添加用户的操作
* @param int $id
* @return string
*/
function addUser(){
$arr=$_POST;
$arr['password']=md5($_POST['password']);
$arr['regTime']=time();
$uploadFile=uploadFile("../uploads");
if($uploadFile&&is_array($uploadFile)){
$arr['face']=$uploadFile[0]['name'];
}else{
return "添加失败<a href='addUser.php'>重新添加</a>";
}
if(insert("imooc_user", $arr)){
$mes="添加成功!<br/><a href='addUser.php'>继续添加</a>|<a href='listUser.php'>查看列表</a>";
}else{
$filename="../uploads/".$uploadFile[0]['name'];
if(file_exists($filename)){
unlink($filename);
}
$mes="添加失败!<br/><a href='addUser.php'>重新添加</a>|<a href='listUser.php'>查看列表</a>";
}
return $mes;
}注册页面:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <h3>添加用户</h3> <form action="doAdminAction.php?act=addUser" method="post" enctype="multipart/form-data"> <table width="70%" border="1" cellpadding="5" cellspacing="0" bgcolor="#cccccc"> <tr> <td>用户名</td> <td><input type="text" name="username" placeholder="请输入管理员名称"/></td> </tr> <tr> <td>密码</td> <td><input type="password" name="password" /></td> </tr> <tr> <td>邮箱</td> <td><input type="text" name="email" placeholder="请输入管理员邮箱"/></td> </tr> <tr> <td>性别</td> <td><input type="radio" name="sex" value="1" checked="checked"/>男 <input type="radio" name="sex" value="2" />女 <input type="radio" name="sex" value="3" />保密 </td> </tr> <tr> <td>头像</td> <td><input type="file" name="myFile" /></td> </tr> <tr> <td colspan="2"><input type="submit" value="添加用户"/></td> </tr> </table> </form> </body> </html>
doAdminAction.php:
<?php
require_once '../include.php';
$act = $_REQUEST['act'];
$id = @$_REQUEST['id'];
if ($act=="logout"){
logout();
}elseif ($act=="addAdmin"){
$mes = addAdmin();
}elseif ($act=="editAdmin"){
$mes = editAdmin($id);
}elseif ($act=="delAdmin"){
$mes = delAdmin($id);
}elseif ($act=="addCate"){
$mes = addCate();
}elseif ($act=="editCate"){
$where = "id={$id}";
$mes = editCate($where);
}elseif ($act=="delCate"){
$mes = delCate($id);
}elseif ($act=="addPro"){
$mes = addPro();
}elseif ($act=="editPro"){
$mes = editPro($id);
}elseif ($act=="delPro"){
$mes = delPro($id);
}elseif ($act=="addUser"){
$mes = addUser();
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
if($mes){
echo $mes;
}
?>
</body>
</html>