这是我的class.admin.php,包含我注册新管理员的功能
public function registro_admin($auser, $aemail, $apass, $adep, $aname, $alast, $agender, $amatricula){
try{
$new_password = password_hash($apass, PASSWORD_BCRYPT);
$stmt = $this->db->prepare("INSERT INTO Admin(admin_user,
admin_email,
admin_password,
admin_departamento,
admin_name,
admin_lastname,
admin_matricula)
VALUES(:auser, :aemail, :apass, :adep, :aname, :alast, :agender, :amatricula)");
$stmt->bindparam(":auser", $auser);
$stmt->bindparam(":aemail", $aemail);
$stmt->bindparam(":apass", $apass);
$stmt->bindparam(":adep", $adep);
$stmt->bindparam(":aname", $aname);
$stmt->bindparam(":alast", $alast);
$stmt->bindparam(":agender", $agender);
$stmt->bindparam(":amatricula", $amatricula);
#$stmt->bindparam(":apic", $apic);
$stmt->execute();
return $stmt;
}catch(PDOException $e){
echo $e->getMessage();
}
}
这是我的admin-register.php,它包含我的html表单和php代码验证
else if(strlen($apass) < 6){
echo '<script>alert("Password must be contain more than 6 characters");</script>';
}else{
try{
$stmt = $db_con->prepare("SELECT admin_user, admin_email FROM Admin WHERE admin_user=:auser OR admin_email=:aemail");
$stmt->execute(array(':auser'=>$auser, ':aemail'=>$aemail));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row['admin_user'] == $auser){
echo '<script>alert("Lo sentimos, el usuario ya existe");</script>';
}
else if($row['admin_email'] == $aemail){
echo '<script>alert("Lo sentimos, el correo ya existe");</script>';
}else{
if($admin->registro_admin($auser, $aemail, $apass, $adep, $aname, $alast, $agender, $amatricula)){
echo '<script>alert("Administrador Agregado con Éxito");</script>';
}
}
}catch(PDOException $e){
echo $e->getMessage();
}
}
请帮助:(
答案 0 :(得分:1)
您的INSERT INTO
中只定义了七列。您需要在那里添加性别列。
请在admin_gender
admin_lastname