Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<!-- table bidon de test CREATE TABLE IF NOT EXISTS `client` ( `id` int(10) NOT NULL AUTO_INCREMENT, `Code` varchar(32) NOT NULL, `Nom` varchar(30) NOT NULL, `Prenom` varchar(30) NOT NULL, `Adresse` varchar(30) NOT NULL, `Tel` varchar(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE= MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; --> <?php if(isset($_POST['Valider'])){ echo ''; print_r($_POST); echo ' '; /*on se connecte et on nettoie*/ mysql_connect('localhost','root',''); mysql_select_db('base1'); /*anti injection + xss*/ foreach($_POST as $k => $v){ $v=mysql_real_escape_string(strip_tags($v)); $_POST[$k]=$v; } /*on extrait le tableau $_POST nettoyé */ extract($_POST); $q= "insert into client values( NULL, '".$Code."', '".$Nom."', '".$Prenom."', '".$Adresse."', '".$Tel."' ) "; /* $db new PDO("mysql:host localhost; dbname=mysql", "root", ""); $req = "insert into client values('".$_GET["Code"]."','".$_GET["Nom"]."','".$_GET["Prenom"]."','".$_GET["Adresse"]."','".$_GET["Tel"]."')"; $db->query($req); */ if(mysql_query($q)){ echo "<html> Client ajouté avec succès </html>"; $q =null;$_POST= array(); }else{ echo "<html> Client pas ajouté </html>"; } }else{ //rien envoyer } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv ="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <form action="" method="post" style=" table-layout:auto; border:solid; border-color: blue;" > Code :, , ---- Nom :, , ---- Prenom :, , ---- Adresse:, , ---- Tel:, , ---- </form> </html>