I want to update some data of my database, but I have an error saying "Undefined index: email" on line 26 and I don't know why. Here's a screenshot of what my form looks like :
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');
?>
Here is the method "email" of the class "Form" in my Form.php document :
public function email($email, $placeholder){
return '<br><label>Email </label><input type="email" name="'.$email.'" placeholder="'. $placeholder .'" class="form-control"><br>';
}
I really don't understand why it's says "Undefined index: email" because, email is defined in this code..
Thanks in advance for the help!