pourquoi il n 'a pas d'insertion dans ma table
<form class="formulaire" name="form1" method="post" action="">
<?php //la function qui va creer la conversation et le message qui va avec function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){ if(isset($_GET['id'])) $id = urldecode($_GET['id']); mysql_query(" INSERT INTO etat_taxation (id,date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('','{$date_impos}','{$noms}','{$ncc}','{$ref_facture}','{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}') ") or die(mysql_error()); } ?>
function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){ if(isset($_GET['id'])) $id = urldecode($_GET['id']); $sql = " INSERT INTO etat_taxation (date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('{$date_impos}','{$noms}','{$ncc}','{$ref_facture}','{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}'))"; mysql_query($sql); return $sql; }
$requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id); Echo $requete ;
<?php if(!isset($_SESSION['pseudo'])){ header("location: index.php?page=BIENVENUE"); } if(isset($_GET['id'])) $id = urldecode($_GET['id']); if(isset($_POST['bouton_submit']) && !empty($_POST['nbre'])){ $date_impos = mysql_real_escape_string(htmlentities(trim($_POST['date_impos']))); $noms = mysql_real_escape_string(htmlentities(trim($_POST['noms']))); $ncc = mysql_real_escape_string(htmlentities(trim($_POST['ncc']))); $ref_facture = mysql_real_escape_string(htmlentities(trim($_POST['ref_facture']))); $natur_bien = mysql_real_escape_string(htmlentities(trim($_POST['natur_bien']))); $montant_total = mysql_real_escape_string(htmlentities(trim($_POST['montant_total']))); $mont_tax_deduct = mysql_real_escape_string(htmlentities(trim($_POST['mont_tax_deduct']))); $code = mysql_real_escape_string(htmlentities(trim($_POST['code']))); //$cat = strip_tags(trim($_POST['cat'])); for($i = 1; $i <= $_POST['nbre']; $i++){ if (empty($code)) { $msg="<font color=red>Verifier que le code est bien dans le champs!!!!!!!!!</font>"; } else { // on regarde si le code existe déjà $sql = "SELECT * FROM etat_taxation WHERE code='$code'"; $req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); // on compte le nombre de résultats $res = mysql_num_rows($req); if($res!=0) // l'url existe déjà, on affiche un message d'erreur { $msg = 'Désolé, mais cette Code existe déjà dans notre base.'; echo '<script>alert(' '.$msg.' ');</script>' ; } else // L'url n'existe pas, on insère les informations du formulaire dans la table { // if(isset($_POST['submit'])){ //creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id); $requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id); Echo $requete ; }}}} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document sans titre</title> <link rel="stylesheet" href="css/style_f.css" /> </head> <body> <div style="background-color: #FFFFFF; width: 960px; height: 1500px; position: absolute; top: 17px; left: 16px; z-index: -2000"> <div style="position: absolute; top: 11px; left: 780px"><img src="images/BV.png" width="100" height="50" /></div> <div style="text-align: center; background-color: #ccc; width: 500px; left: 201px; position: absolute; top: 25px; z-index: -1000;">ETAT DES TAXATIONS DEDUCTIBLES</div> <p> </p> <div style="position:absolute; top:200px; left:25px"> <fieldset style="width: 814px; border-color: #1E1E1E; position: absolute; top: -132px; left: -12px; height: auto;" > <legend><span class="Style2"> ETAT DES TAXATIONS DEDUCTIBLES</span></legend> <form class="formulaire" name="form1" method="post" action=""> <table width="312" border="0"> <tr> <td width="121">Saisir le nombre</td> <td width="33"><input name="nbre" type="text" size="1" maxlength="1" value="<?php if(isset($_POST['nbre']))echo $_POST['nbre'];?>"/></td> <td width="34"> </td> </tr> </table> <p> <?php if(isset($_POST['bouton_submit']) && ($_POST['nbre'])){ extract($_POST); $nbre_photo = $nbre; for($j = 1; $j<= $nbre_photo; $j++){ //ENREGISTREMENT DU CODE $sql = ('SELECT (max(code)+1) AS code FROM etat_taxation'); $q = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); while($row = mysql_fetch_assoc($q)){ $code = $row["code"]; } echo' <table width="860" height="45" border="0" bgcolor="#fff align="center="center""> <tr> <td width="111"><input type="text" name="date_impos'.$j.'" id="date_impos" style="width:80px; text-align:center"" placeholder="Date" /></td> <td width="206" height="41"><input type="text" name="noms'.$j.'" id="noms" style="width:150px; text-align:center"" placeholder="Noms" /></td> <td width="85" height="41"><input type="text" name="ncc'.$j.'" style="width:60px" id="ncc" placeholder="NCC" /></td> <td width="125" height="41"><input type="text" name="ref_facture'.$j.'" id="ref_facture" style="width:80px" placeholder="Ref"; text-align:center" /></td> <td width="118" height="41"><input type="text" name="natur_bien'.$j.'" id="natur_bien" style="width:80px; text-align:center"" placeholder="Nat B." /></td> <td width="115"><input type="text" name="montant_total'.$j.'" id="montant_total" style="width:80px; text-align:center"" placeholder="MT" /></td> <td width="250" height="41"><input type="text" name="mont_tax_deduct'.$j.'" id="mont_tax_deduct" style="width:80px; text-align:center" placeholder="MTD" /></td> <td width="250" height="41"><input type="text" name="code'.$j.'" id="code" value="'.$code.'" style="width:80px;background-color:#E8E8E8; text-align:center"" placeholder="Code" /></td> </tr> </table> ';} } ?> <input type="submit" name="bouton_submit" value="envoyer" /> </p> </form></input> </form> </fieldset> </body> </html>
<?php function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){ if(isset($_GET['id'])) $id = urldecode($_GET['id']); $sql = "INSERT INTO etat_taxation (date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('{$date_impos}','{$noms}','{$ncc}','{$ref_facture}',{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}')"; mysql_query($sql); return $sql; } ?>
Ceci est du code dans les balises < code > !
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionvoici la nouvelle structure de ma table- Pourquoi avoir modifié la structure de ta table ?
if(isset($_GET['id'])) $id = urldecode($_GET['id']);me parait étrange...
ah ook je comprend . mais j'arrive pas toujours a inserrer mes donnéesTu comprends quoi ?
INSERT INTO etat_taxation (date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('07/10/2013','ECOGEP-CI','010075E','3-1-5-0519626','MATERIELS','260455','39733','1','1');
essuite quand je fais echo ça n'affiche rienAh.. donc tu ne sors pas de ta fonction (ou voir même tu n'y rentre pas).
Echo "<br> ----- CREATION ETAT TAXATION ---------<br>"; //creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id); $requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id); Echo "<br>Requete = ". $requete ;
// if (empty($code)) { //$msg="<font color=red>Verifier que le code est bien dans le champs!!!!!!!!!</font>"; //} //else {
<?php if(isset($_GET['id'])); $id =$_GET['id']; echo $id; if(isset($_POST['bouton_submit'])&& !empty($_POST['nbre'])){ $cat = strip_tags(trim($_POST['cat'])); for($i = 1; $i <= $_POST['nbre']; $i++){ $date_impos = mysql_real_escape_string(htmlspecialchars(trim($_POST['date_impos'.$i]))); $noms = mysql_real_escape_string(htmlspecialchars(trim($_POST['noms'.$i]))); $ncc = mysql_real_escape_string(htmlspecialchars(trim($_POST['ncc'.$i]))); $ref_facture = mysql_real_escape_string(htmlspecialchars(trim($_POST['ref_facture'.$i]))); $natur_bien = mysql_real_escape_string(htmlspecialchars(trim($_POST['natur_bien'.$i]))); $montant_total = mysql_real_escape_string(htmlspecialchars(trim($_POST['montant_total'.$i]))); $mont_tax_deduct = mysql_real_escape_string(htmlspecialchars(trim($_POST['mont_tax_deduct'.$i]))); $code = mysql_real_escape_string(htmlspecialchars(trim($_POST['code'.$i]))); if (empty($code)) { $msg="<font color=red>Veuillez saisir le code !!!!!!!!!</font>"; }else{ $requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id); echo $requete ; } } } //} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Document sans titre</title> </head> <body> <div style="position:absolute; top:600px; left:295px"> <fieldset style="width: 921px; border-color: #1E1E1E; position: absolute; top: -570px; left: -292px; height: auto;" > <legend><span class="Style2"> RESULTATS ETAT DES TAXATIONS DEDUCTIBLES</span></legend> <form action="" method="post" > <table width="1195" height="95" border="0" align="center" bordercolor="#FFF" > <tr> <td width="1115">Saisir le nombre :<input name="nbre" type="text" size="1" maxlength="1" value="<?php if(isset($_POST['nbre']))echo $_POST['nbre'];?>"/></td> </tr> <tr> <td bordercolor="#0000FF"> <fieldset style="background-color:#FFF; height:250px; width:400px; border-color:#1B1B1B;"> <legend><span class="Style6">AJOUTER </span></legend> <?php if(isset($_POST['bouton_submit']) && ($_POST['nbre'])){ extract($_POST); $nbre_photo = $nbre; for($j = 1; $j<= $nbre_photo; $j++){ //ENREGISTREMENT DU CODE $sql = ('SELECT (max(code)+1) AS code FROM etat_taxation'); $q = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); while($row = mysql_fetch_assoc($q)){ $code = $row["code"]; } echo' <table width="860" height="45" border="0" bgcolor="#fff align="center="center""> <tr> <td width="111"><input type="text" name="date_impos'.$j.'" id="date_impos" style="width:80px; text-align:center"" placeholder="Date" /></td> <td width="206" height="41"><input type="text" name="noms'.$j.'" id="noms" style="width:150px; text-align:center"" placeholder="Noms" /></td> <td width="85" height="41"><input type="text" name="ncc'.$j.'" style="width:60px" id="ncc" placeholder="NCC" /></td> <td width="125" height="41"><input type="text" name="ref_facture'.$j.'" id="ref_facture" style="width:80px" placeholder="Ref"; text-align:center" /></td> <td width="118" height="41"><input type="text" name="natur_bien'.$j.'" id="natur_bien" style="width:80px; text-align:center"" placeholder="Nat B." /></td> <td width="115"><input type="text" name="montant_total'.$j.'" id="montant_total" style="width:80px; text-align:center"" placeholder="MT" /></td> <td width="250" height="41"><input type="text" name="mont_tax_deduct'.$j.'" id="mont_tax_deduct" style="width:80px; text-align:center" placeholder="MTD" /></td> <td width="250" height="41"><input type="text" name="code'.$j.'" id="code" value="'.$code.'" style="width:80px;background-color:#E8E8E8; text-align:center"" placeholder="Code" /></td> </tr> </table> '; } } ?> </fieldset> </td> </tr> <tr> <td><input type="submit" name="bouton_submit" value="envoyer" ></input></td> </tr></table> </form></fieldset> </div> <?php $color=array('#333333','#999999'); $i=0; // on crée la requête SQL $sql = "SELECT * FROM etat_taxation WHERE code = '".$_POST['code']."'"; // on envoie la requête $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); $res = mysql_num_rows($req); // 4 ?> <div style="position:absolute; top:600px; left:295px"> <fieldset style="width: 921px; border-color: #1E1E1E; position: absolute; top: 37px; left: -285px; height: auto;" > <legend><span class="Style2"> RESULTATS ETAT DES TAXATIONS DEDUCTIBLES</span></legend> <table width="900" style=" border-width:5px; border-style:solid; border-color:red;width:100%; align="center" " border="0" align="center" cellspacing="2"> <tr bgcolor="#999999"> </tr> <tr bgcolor="#999999"> <th width="86" bgcolor="#fff" scope="row" style=" border-width:2px; border-style:solid; border-color:red;width:18%; " ><p class="Style8">DATE DE LA FACTURE OU DE L IMPOSITION</p></th> <td width="101" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:28%; " ><div align="center" class="Style10">NOM ET PRENOMS</div></td> <td width="113" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:10%; " ><div align="center" class="Style10">N° CC</div></td> <td width="119" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:30%; " ><div align="center" class="Style10">REFERENCE DE LA FACTURE OU N° DE LA DECLARATION ET DE LA LIQUIDATION DOUANE</div></td> <td width="62" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:100%; " ><div align="center" class="Style10"> <p>NATURE DES BIENS OU SERVICES</p> <p>(ouvrant droit a deduction)</p> </div></td> <td width="111" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:100%; " ><div align="center" class="Style10">MONTANT TOTAL</div></td> <td width="111" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:100%; " ><div align="center" class="Style10">MONTANT DE LA TAXE DEDUCTIBLE</div></td> </tr> <?php while ($liste_etu=mysql_fetch_assoc($req)) { $j=$i%2; ?> <tr bgcolor=#33FFFF> <td bgcolor="#F2D113"><?php echo $liste_etu['date_impos'] ?></td> <td bgcolor="#F2D113"><?php echo $liste_etu['noms'] ?></td> <td bgcolor="#F2D113"><?php echo $liste_etu['ncc'] ?></td> <td bgcolor="#F2D113"><?php echo $liste_etu['ref_facture'] ?></td> <td bgcolor="#F2D113"><?php echo $liste_etu['natur_bien'] ?></td> <td bgcolor="#F2D113"><?php echo $liste_etu['montant_total'] ?></td> <td bgcolor="#F2D113"><?php echo $liste_etu['mont_tax_deduct'] ?></td> </tr> <?php } ?> </table> </fieldset> </div> </div> </div> </body> </html>
<?php function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){ if(isset($_GET['id'])) $id = urldecode($_GET['id']); $sql = "INSERT INTO etat_taxation (id,date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('','{$date_impos}','{$noms}','{$ncc}','{$ref_facture}','{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}')"; mysql_query($sql); return $sql; } ?>