doupuchao4256 2019-02-15 22:09
浏览 516

为什么在实际定义时会出现未定义的索引错误?

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 :

Form to update in database form to update in database

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题