[RESOLU] Pourquoi j'ai pas d'insertion dans ma table

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : [RESOLU] Pourquoi j'ai pas d'insertion dans ma table

Re: Pourquoi j'ai pas d'insertion dans ma table

par msi79 » 08 oct. 2013, 13:22

merci de bien vouloir me repondre .
voici le code de page.func.php
<?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;
}
?>

Re: Pourquoi j'ai pas d'insertion dans ma table

par xTG » 08 oct. 2013, 13:16

L'insertion se fait dans la fonction creer_etat_taxation ?
Auquel cas il va nous falloir son code...
Si ce n'est pas cela... Bah il te manque un code d'insertion. :)

Re: Pourquoi j'ai pas d'insertion dans ma table

par msi79 » 07 oct. 2013, 21:14

comment à $code n'existe pas je comprend pas . j'ai mi
 $code = mysql_real_escape_string(htmlentities(trim($_POST['code'])));
au dessus mais toujours rien
voici le code;
<?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);	
}}}}
?>

Re: Pourquoi j'ai pas d'insertion dans ma table

par moogli » 07 oct. 2013, 19:22

Salut,

$code n'existe pas !

@+

Pourquoi j'ai pas d'insertion dans ma table

par msi79 » 07 oct. 2013, 18:50

bonjour à tous depuis hier je cherche le problème dans mon code. j'arrive pas a savoir pourquoi il n 'a pas d'insertion dans ma table
voici la stucture de ma table:
[mysql]
--
-- Base de données: `bdd`
--

-- --------------------------------------------------------

--
-- Structure de la table `etat_taxation`
--

CREATE TABLE IF NOT EXISTS `etat_taxation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date_impos` varchar(60) NOT NULL,
`noms` varchar(200) NOT NULL,
`ncc` varchar(30) NOT NULL,
`ref_facture` varchar(60) NOT NULL,
`natur_bien` varchar(60) NOT NULL,
`montant_total` varchar(30) NOT NULL,
`mont_tax_deduct` varchar(30) NOT NULL,
`code` int(11) NOT NULL,
`get_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
COMMIT;
[/mysql]
et voici mon code :
<?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'])){
		//$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 l'url 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 
        { 
	      $date_impos = mysql_real_escape_string(htmlentities(trim($_POST['date_impos'.$i])));
		  $noms =  mysql_real_escape_string(htmlentities(trim($_POST['noms'.$i])));
		  $ncc =  mysql_real_escape_string(htmlentities(trim($_POST['ncc'.$i])));
		  $ref_facture =  mysql_real_escape_string(htmlentities(trim($_POST['ref_facture'.$i])));
		  $natur_bien =  mysql_real_escape_string(htmlentities(trim($_POST['natur_bien'.$i])));
		  $montant_total =  mysql_real_escape_string(htmlentities(trim($_POST['montant_total'.$i])));
		  $mont_tax_deduct = mysql_real_escape_string(htmlentities(trim($_POST['mont_tax_deduct'.$i])));
		  $code =  mysql_real_escape_string(htmlentities(trim($_POST['code'])));
		 
creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id);	
}}}}
?>
<!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>&nbsp;</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">&nbsp;</td>
  </tr>
</table>


  <table width="806" height="162" border="0" bgcolor="#fff align="center">
    <tr>
      <td width="707" colspan="7"><?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>
   
   
 ';}
  }
?></td>
    </tr>
  </table>
  <input type="submit" name="bouton_submit" value="envoyer" ></input>
</form>
</fieldset>



<p>&nbsp;</p>
</body>
</html>