1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <?php
//include ("connexion.php");
try
{
$_bdd = new PDO('mysql:host=localhost;dbname=electrofield', 'root', '');
$_bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
}catch(Exception $e) {
die ('Echec ! : '.$e->getMessage());
}
$test = (isset($_GET['test'])) ? $_GET['test'] : '';
$id_membre = (isset($_POST['id_membre'])) ? $_POST['id_membre'] : '';
$email = (isset($_POST['email'])) ? $_POST['email'] : '';
if($test=='ajout' && $id_membre!="" && $email!="")
{
$stmt = $_bdd->prepare('INSERT INTO membres(id_membre, email) VALUES(:id_membre, :email)');
$stmt = execute(array(':id_membre' => $id_membre, ':email' => $email));
}
?>
<form method="post" ACTION='index.php?test=ajout'>
ID : <input type="text" name="id_membre"><br>
eMail : <input type="text" name="email"><br>
<input type="submit" value="ENVOYER"
style="cursor:hand;"></form>
} |