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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Formulaire pour profils</title>
</head>
<body>
<p> Formulaire pour data profils</p>
<form method="post" action="requete-preparee.php">
<p> <label>Prenom</label> : <input type="text" name="Prenom"></p>
<p><label>Nom</label> : <input type="text" name="Nom"/></p>
<p> <label>Adresse</label> : <input type="text" name="Adresse"/></p>
<p><label>Code postal</label> : <input type="text" name="Code_postal"/></p>
<p> <label>Ville</label> : <input type="text" name="Ville"/></p>
<p> <label>Pays</label> : <input type="text" name="Pays"/></p>
<p> <label>Tel</label> : <input type="text" name="Tel"/></p>
<p><label>Email</label> : <input type="text" name="Email"/></p>
<p><label>Competences</label> : <input type="text" name="Competences"/></p>
<p><input type="submit" value="Envoyer" /></p>
</form>
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=mes_contacts;charset=utf8', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$Prenom = htmlspecialchars($_POST['Prenom']);
echo '<p>'.$Prenom.'</p>';
$Nom = htmlspecialchars($_POST['Nom']);
echo '<p>'.$Nom.'</p>';
$Adresse = htmlspecialchars($_POST['Adresse']);
echo '<p>'.$Adresse.'</p>';
$Ville = htmlspecialchars($_POST['Ville']);
echo '<p>'.$Ville.'</p>';
$Code = htmlspecialchars($_POST['Code_postal']);
echo '<p>'.$Code.'</p>';
$Pays = htmlspecialchars($_POST['Pays']);
echo '<p>'.$Pays.'</p>';
$Tel = htmlspecialchars($_POST['Tel']);
echo '<p>'.$Tel.'</p>';
$Email = htmlspecialchars($_POST['Email']);
echo '<p>'.$Email.'</p>';
$Comp = htmlspecialchars($_POST['Competences']);
echo '<p>'.$Comp.'</p>';
$req = $bdd->prepare('INSERT INTO profils(Prenom, Nom, Adresse, Code_postal, Ville, Pays, Tel, Email, Competences) VALUES(:Prenom, :Nom, :Adresse, :Code_postal, :Ville, :Pays, :Tel, :Email, :Competences)');
$req->execute(array(
'Prenom'=>$Prenom,
'Nom'=>$Nom,
'Adresse'=>$Adresse,
'Code_postal'=>$Code,
'Ville'=>$Ville,
'Pays'=>$Pays,
'Tel' => $Tel,
'Email'=>$Email,
'Competences'=>$Comp));
?>
</body>
</html> |