1 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
未定義索引錯(cuò)誤來自 $_POST 變量。當(dāng)您嘗試emailsignup參數(shù)nom, birthday...時(shí),$_POST 數(shù)組中不存在。你可以這樣做:
// 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 關(guān)注
- 157 瀏覽
添加回答
舉報(bào)