1 回答
TA贡献1828条经验 获得超3个赞
未定义索引错误来自 $_POST 变量。当您尝试emailsignup参数nom, birthday...时,$_POST 数组中不存在。你可以这样做:
// Sous WAMP
$bdd = new PDO('mysql:host=localhost;dbname=test exbook;charset=utf8', 'root', '');
$reponse = $bdd ->query('SELECT * FROM registration');
$hasnom=isset($_POST['nom']);
$hasbirthday=isset($_POST['birthday']);
$hasgenre=isset($_POST['genre']);
$hasemail=isset($_POST['email']);
$haspass = $isset($_POST['pass']);
if ($hasnom && $hasbirthday && $hasgenre && hasemail && haspass) {
$nom=$_POST['nom'];
$birthday=$_POST['birthday'];
$genre=$_POST['genre'];
$email=$_POST['email'];
$password=password_hash($_POST['password'], PASSWORD_DEFAULT);
$req = $bdd ->prepare('INSERT INTO registration(`Nom`, `Date de naissance`, `Genre`, `Email`, `Password`) VALUES(?,?,?,?,?)');
$req->execute(array($nom,$birthday,$genre,$email,$password));
}
while ($donnees = $reponse->fetch())
{
echo $donnees['Nom'];
}
?>
<?php
$bdd = new PDO('mysql:host=localhost;dbname=test exbook;charset=utf8', 'root', '');
$hasemailsignup=isset($_POST['emailsignup']);
if ($hasemailsignup) {
$emailsignup = $_POST['emailsignup'];
$bdd1=$bdd ->query('SELECT * FROM registration WHERE $emailsignup');
}
?>
- 1 回答
- 0 关注
- 119 浏览
添加回答
举报