1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <body>
<br>Pour vous inscrire remplissez ces cases :<br>
<form method="post" action="insertpdo.php">
Nom : <input type="text" name="nom">
Email : <input type="text" name="email">
<input type="submit" name="submit" value="Je valide mon inscription">
</form>
<?php
if(isset($nom)){
$nom=$_POST['nom'];
$email=$_POST['email'];
try{
$connexion=new PDO('mysql:host=localhost;dbnane=test','root','');
}
catch(PDOExcetion $e){
die("Erreur de connexion".$e->getMessage());
}
$req=$connexion->prepare("INSERT INTO gens (nom,email) VALUES(:nom,:email)");
$req->execute(array('nom'=>$nom,'email'=>$email))
$connexion = NULL;
}
?>
</body> |
Partager