lecjoh,
il y a 10 ans
<?php
error_reporting(E_ALL);
if(isset($_POST['submit']))
{
$nom =htmlentities(trim($_POST['nom']));
$prenom =htmlentities(trim($_POST['prenom']));
$adresse =htmlentities(trim($_POST['adresse']));
$ville =htmlentities(trim($_POST['ville']));
$nombre_enfant =htmlentities(trim($_POST['nombre_enfant']));
$nomenfant =htmlentities(trim($_POST['nomenfant']));
$bdd = new PDO('mysql:host=localhost;dbname=phplogin;charset=utf8', 'root', '');
try
{
$bdd = new PDO('mysql:host=localhost;dbname=phplogin;charset=utf8', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
mysql_select_db('phplogin');
$req = mysql_query("SELECT * FROM inscription WHERE nom='$nom', prenom='$prenom', adresse='$adresse', ville='$ville', nombre_enfant=$nombre_enfant, nomenfant='$nomenfant'");
$req = $bdd->prepare("INSERT INTO inscription (nom, prenom, adresse, ville, nombre_enfant, nomenfant) VALUES (:nom, :prenom, :adresse, :ville, nombre_enfant, nomenfant)");
$req->execute(array("nom" => $nom, "prenom"=> $prenom, "adresse" => $adresse, "ville" => $ville, "nombre_enfant" => $nombre_enfant, "nomenfant" => $nomenfant));
}
?>
Azorgh,
il y a 10 ans
Fais attention à la casse !
<select name="Nombre_enfant">
</select>
$nombre_enfant =htmlentities(trim($_POST['nombre_enfant']));
Donc modifie l'un des deux pour qu'il concorde.
Ensuite je te conseil de revoir ton code php. Dans ta préparation de requête des fois du as : ":var" et d'autre "var".
VALUES (:nom, [..], variable) //Sans les ":"
Donc refait un tour.
Le mieux a faire avant de test les INSERT, c'est de tester si tu as bien toutes les données , donc avant ton $bdd = new PDO...,tu peux faire un
die(print_r(array("nom" => $nom, "prenom"=> $prenom, "adresse" => $adresse, "ville" => $ville, "nombre_enfant" => $nombre_enfant, "nomenfant" => $nomenfant)));
Et voir si les informations sont celles soumises.