vendredi 24 juillet 2020

How can i disable or affect null to a variable in php

I have 3 web pages one for sign-in, one for sign-up, and the last one is the home page (index). I have 2 variables from the sign-in and 5 variable from sign-up, all the variables are sent into the home page so when I sign up in the sign-in variable have no values so it gives an error "notice undefined index", and when I sign up the same happens but the error shows the sign in's variables. I have so many searches in google and I've found a function called unset to disable the variables, but nothing happens.

// Sous WAMP
$bdd = new PDO('mysql:host=localhost;dbname=test exbook;charset=utf8', 'root', '');
$reponse = $bdd->query('SELECT * FROM registration');
$nom = $_POST['nom'];
$birthday = $_POST['birthday'];
$genre = $_POST['genre'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);

if (isset($nom , $birthday , $genre , $email, $password )) {
    unset($nom);
    unset($birthday);
    unset($genre);
    unset($email);
    unset($password);
} else {
    $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'];
}

$bdd = new PDO('mysql:host=localhost;dbname=test exbook;charset=utf8', 'root', '');
$emailsignup = $_POST['emailsignup'];
if (isset($emailsignup)) {
    unset($emailsignup);
} else{
    $bdd1 = $bdd->query('SELECT * FROM registration WHERE $emailsignup');
}

Thank you for reading this, and for trying to help. Have a nice day :)




Aucun commentaire:

Enregistrer un commentaire