我想更新数据库的某些数据,但是在第26行上显示“未定义索引:电子邮件”错误,我不知道为什么。 这是我的表单的屏幕截图:
if(isset($_GET['idUser']) AND !empty($_GET['idUser'])){
$idUser = $_GET['idUser'];
if(isset($_POST['email']) AND !empty($_POST['email'])){
$updateEmail = $bdd->prepare('UPDATE USERS SET email = :email WHERE id_user = :id_user');
$updateEmail->execute(array(
"email" => htmlspecialchars($_POST['email']),
"id_user" => $_GET['idUser']
));
}
$editUser = $bdd->prepare('SELECT * FROM USERS WHERE id_user = ?');
$editUser->execute(array($idUser));
$editUser = $editUser->fetch(); ?>
<form action="" method="POST" class="container form-control text-center">
<h3>Compte de :
<?php echo $editUser['first_name']; ?> <?php
echo $editUser['last_name']; ?></h3>
<?php
echo $Form->input('nom',$editUser['last_name']);
echo $Form->input('prenom',$editUser['first_name']);
echo $Form->email('email',$editUser['email']);
echo $Form->submit('btn btn-dark');
?>
这是我的Form.php文档中“ Form”类的“ email”方法:
public function email($email, $placeholder){
return '<br><label>Email </label><input type="email" name="'.$email.'" placeholder="'. $placeholder .'" class="form-control"><br>';
}
我真的不明白为什么它说“未定义索引:电子邮件”,因为电子邮件是在此代码中定义的。
预先感谢您的帮助!