begin process at 2012 05 31 01:48:53
  Trouver un code source :
 
dans
 
Accueil > Forum > 

PHP

 > 

Base de données

 > 

MySQL

 > 

problème d'insertion des données dans ma base de données en php


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

problème d'insertion des données dans ma base de données en php

lundi 15 août 2011 à 11:08:23 | problème d'insertion des données dans ma base de données en php

Bades

salut à tous,
je suis en train de réaliser un formulaire en php ,mon formulaire est relié à une Base de données. Mon problème, quand je rempli le formulaire,les enregistrements ne sont pas pris en compte dans la base de donnée. si quelqu'un pouvait me donner un coup de main. voici mes différents formulaires

fichesaisie.php
<form action="serv_fichesaisie.php" method="post">
<table width="835" border="0">

<td width="673" align="center">
<table border="1" align="center" bgcolor="#CCCCCC" class="dTable">
<thead>
<td colspan="5"><div align="center"><strong>SAISIE DES NOTES DE L'ELEVE</strong></div></td>
<tr>
<th>Matieres Spécifiques</th>
<th>1er Trimestre </th>

<th>2ème Trimestre</th>


<th>3ème Trimestree</th>

<th>Moyenne Anuelle</th>
</tr>

<tr>
<td><input name="matiere[]" type="texte" disabled="disabled" value="FRANCAIS" /></td>
<td><input type="text" id="ch1" name="notfranc1" /></td>
<td><input type="text" id="ch2" name="notfranc2" /></td>
<td><input type="text" id="ch3" name="notfranc3" /></td>
<td><input type="text" id="ch4" name="notfranc4" /></td>
</tr>

<tr>
<td><input name="matiere[]" type="texte" disabled="disabled" value="MATHEMATIQUES" /></td>
<td><input type="text" id="ch1" name="notmath1" /></td>
<td><input type="text" id="ch2" name="notmath2" /></td>
<td><input type="text" id="ch3" name="notmath3" /></td>
<td><input type="text" id="ch4" name="notmath4" /></td>
</tr>
<tr>
<td><input name="matiere[]" type="texte" disabled="disabled" value="ANGLAIS" /></td>
<td><input type="text" id="ch1" name="notanglais1" /></td>
<td><input type="text" id="ch2" name="notanglais2" /></td>
<td><input type="text" id="ch3" name="notanglais3" /></td>
<td><input type="text" id="ch4" name="notanglais4" /></td>
</tr>

<tr>
<td><input name="matiere[]" type="texte" disabled="disabled" value="SCIENCES PHYSIQUES" /></td>
<td><input type="text" id="ch1" name="notphys1" /></td>
<td><input type="text" id="ch2" name="notphys2" /></td>
<td><input type="text" id="ch3" name="notphys3" /></td>
<td><input type="text" id="ch4" name="notphys4" /></td>
</tr>

<tr>
<td><input name="matiere[]" type="texte" disabled="disabled" value="ORTHOGRAPHE" /></td>
<td><input type="text" id="ch1" name="notortho1" /></td>
<td><input type="text" id="ch2" name="notortho2" /></td>
<td><input type="text" id="ch3" name="notortho3" /></td>
<td><input type="text" id="ch4" name="notortho4" /></td>
</tr>
<tr>
<td><input name="matiere[]" type="texte" disabled="disabled" value="HISTOIRE GEOGRAPHIE" /></td>
<td><input type="text" id="ch1" name="histgeo1" /></td>
<td><input type="text" id="ch2" name="histgeo2" /></td>
<td><input type="text" id="ch3" name="histgeo3" /></td>
<td><input type="text" id="ch4" name="histgeo4" /></td>
</tr>
<tr>
<td><input name="matiere[]" type="texte" disabled="disabled" value="SVT" /></td>
<td><input type="text" id="ch1" name="notsvt1" /></td>
<td><input type="text" id="ch2" name="notsvt2" /></td>
<td><input type="text" id="ch3" name="notsvt3" /></td>
<td><input type="text" id="ch4" name="notsvt4" /></td><br />
</tr>

<tr><td colspan="5" bgcolor="#CCCCCC"><div align="center"><strong>AUTRES INFORMATION</strong></div></td>
<tr>
<td width="116"> Résultat
<select name="ResultatExamenCand" id="SexeCand">
<option value="admis">Admis(e)</option>
<option value="refus">refusé</option>
</select> <td colspan="2">Sélectionnez un élément. Handicap
</td>

<td width="144">Métier
<input name="metier" type="texte" /></td>
<td width="153" colspan="2">Sélectionnez un élément. Handicap<input name="HandicapCand" type="texte" /></td>
</tr>
<tr>
<td height="72">double selection
<select name="DoubleSelectCand" id="DoubleSelectCand">
<option value="technique">technique</option>
<option value="refus">general</option>
</select> </td>
<td width="144">Résidence des parent
<input type="text" name="residenceParentCand" /></td>
<td width="160">Personne prise en charge
<select name="PersoneEnChargeCand" id="PersoneEnChargeCand">
<option value="parent">Parent</option>
<option value="tuteur">Tuteur</option>
</select> </td>
<td width="144">Contact
<input type="text" name="CelCand" /></td>
</tr>
</table>

<p align="center">&nbsp;</p>
<table border="1" bgcolor="#CCCCCC" align="center">
<tr><td colspan="3"> <p align="center"><strong>VOEUX D'ORIENTATION DE L'ELEVE </strong></p></td></tr>
<tr>
<td width="231">FILIERES(Entrée le code de la filière)</td>
<td colspan="2"><p align="center">ETABLISSEMENTS (Entrée le code de l'établissement)</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td rowspan="5"><input type="text" name="filieres" /></td>
<td width="100" height="">
<p><input type="text" name="filiere1" /></p>
</td>
<td width="273">1er Etablissement</td>
</tr>
<tr>
<td><input type="text" name="filiere2" /></td>
<td>2ème Etablissement</td>
</tr>
<tr>
<td height="21"><input type="text" name="filiere3" /></td>
<td height="21">2ème Etablissement</td>
</tr>
</table>
<tr><td><div align="center">
<input type="submit" name="validation" value="valider" /></div></td>

</tr>
</form>

voici le formulaire serveur
serv_fichesaisie.php

<?php session_start(); require_once('connexion.php'); ?>
<?php
mysql_select_db($database_dbprotect, $dbprotect);

if ((isset($_POST['validation'])) && $_POST['validation'] == "valider") {

echo "<pre>";
print_r($_POST);
echo "</pre>";

extract($_POST);


//$francais=addslashes($_POST["francais"]);
$notfranc1 = addslashes($_POST["notfranc1"]);
$notfranc2 = addslashes($_POST["notfranc2"]);
$notfranc3 = addslashes($_POST["notfranc3"]);
$notfranc4 = addslashes($_POST["notfranc4"]);

//$math=addslashes($_POST["math"]);
$notmath1 = addslashes($_POST["notmath1"]);
$notmath2 = addslashes($_POST["notmath2"]);
$notmath3 = addslashes($_POST["notmath3"]);
$notmath4 = addslashes($_POST["notmath4"]);

//$anglais=addslashes($_POST["anglais"]);
$notanglais1 = addslashes($_POST["notanglais1"]);
$notanglais2 = addslashes($_POST["notanglais2"]);
$notanglais3 = addslashes($_POST["notanglais3"]);
$notanglais4 = addslashes($_POST["notanglais4"]);

//$scphys=addslashes($_POST["scphys"]);
$notphys1 = addslashes($_POST["notphys1"]);
$notphys2 = addslashes($_POST["notphys2"]);
$notphys3 = addslashes($_POST["notphys3"]);
$notphys4 = addslashes($_POST["notphys4"]);

//$ortho=addslashes($_POST["ortho"]);
$notortho1 = addslashes($_POST["notortho1"]);
$notortho2 = addslashes($_POST["notortho2"]);
$notortho3 = addslashes($_POST["notortho3"]);
$notortho4 = addslashes($_POST["notortho4"]);

//$histgeo=addslashes($_POST["histgeo"]);
$histgeo1 = addslashes($_POST["histgeo1"]);
$histgeo2 = addslashes($_POST["histgeo2"]);
$histgeo3 = addslashes($_POST["histgeo3"]);
$histgeo4 = addslashes($_POST["histgeo4"]);

//$svt=addslashes($_POST["svt"]);
$notsvt1 = addslashes($_POST["notsvt1"]);
$notsvt2 = addslashes($_POST["notsvt2"]);
$notsvt3 = addslashes($_POST["notsvt3"]);
$notsvt4 = addslashes($_POST["notsvt4"]);

$ResultatExamenCand = addslashes($_POST["ResultatExamenCand"]);
$metier = addslashes($_POST["metier"]);
$HandicapCand = addslashes($_POST["HandicapCand"]);
$DoubleSelectCand = addslashes($_POST["DoubleSelectCand"]);
$residenceParentCand = addslashes($_POST["residenceParentCand"]);
$PersoneEnChargeCand = addslashes($_POST["PersoneEnChargeCand"]);
$CelCand = addslashes($_POST["CelCand"]);

$validation = array();

for($u=0;$u < $count($matiere);$u++)

{

$matiere = $matiere[$u];


$requete = "INSERT INTO note (trimestre1 , trimestre2, trimestre3,moyenannuel)VALUES ('',";
switch ($matiere) {
case "FRANCAIS":

$parametres = $notfranc1."', '".$notfranc2."', '".$notfranc3."', '".$notfranc4."'";
break;

case "MATHEMATIQUES":

$parametres = $notmath1."', '".$notmath2."', '".$notmath3."', '".$notmath4."'";
break;

case "ANGLAIS":

$parametres = $notanglais1."', '".$notanglais2."', '".$notanglais3."', '".$notanglais4."'";
break;

case "SCIENCES PHYSIQUES":

$parametres = $notphys1."', '".$notphys2."', '".$notphys3."', '".$notphys4."'";
break;

case "ORTHOGRAPHE":

$parametres = $notortho1."', '".$notortho2."', '".$notortho3."', '".$notortho4."'";
break;

case "HISTOIRE GEOGRAPHIE":

$parametres = $histgeo1."', '".$histgeo2."', '".$histgeo3."', '".$histgeo4."'";
break;

case "SVT":

$parametres = $notsvt1."', '".$notsvt2."', '".$notsvt3."', '".$notsvt4."'";
break;

}

$tableau[1] = $requete .= $parametres.'")";';

$tableau[2] = $requete_info = "INSERT INTO candidat (ResultatExamenCand ,metier, Handicap,DoubleSelectCand,residenceParentCand,PersoneEnChargeCand,CelCand )VALUES ('', '$ResultatExamenCand', '$metier', '$Handicap', '$DoubleSelectCand','$residenceParentCand','$PersoneEnChargeCand','$CelCand')";


function validiter_execution($requete_a_executer)
{
return (mysql_query($requete_a_executer)) ? true : false;

}


$statut_execution_requete = "";
for($i=0;$i< count($tableau);$i++)
{
$statut_execution_requete = validiter_execution($tableau[$i]);

}

$validation[$u] = $statut_execution_requete;

}

// if (in_array(false, $validation)) // validation a tester
//
// {
// echo "<h3>l'inscription a ´chou´e</h3>";
// }
// else
// {
// echo "<h3>l'inscription a été effectuée avec succès</h3>";
// }

echo "<h3>l'inscription a été effectuée avec succès</h3>";



echo "<a href=\"Inscription.html\">Nouvelle inscription</a>";
echo "<br><a href=\"Consultation.php\">Consulter la liste</a>";
}
?>

lundi 15 août 2011 à 12:10:10 | Re : problème d'insertion des données dans ma base de données en php

cod57


bonjour
tu devalides requires_once
et une erreur
Notice: Undefined variable: count in C:\wamp\www\romain\bades\serv_fichesaisie.php on line 73
Fatal error: Function name must be a string in C:\wamp\www\romain\bades\serv_fichesaisie.php on line 73


cette variable n'existe pas pas mais
fait ex

//$count($matiere)
for($u=0;$u < 7;$u++)

tu mets des echo devant tes requetes et tu veras un peu plus clair
Code PHP :
<?php
echo '<pre>';
print_r($_POST);

session_start();
//require_once('connexion.php');
?> 

tu fais un extract qui sert a rien il me semble ...
<?php 
mysql_select_db($database_dbprotect, $dbprotect); 

if ((isset($_POST['validation'])) && $_POST['validation'] == "valider") { 

echo "<pre>"; 
print_r($_POST); 
echo "</pre>"; 

extract($_POST); 


//$francais=addslashes($_POST["francais"]); 
$notfranc1 = addslashes($_POST["notfranc1"]); 
$notfranc2 = addslashes($_POST["notfranc2"]); 
$notfranc3 = addslashes($_POST["notfranc3"]); 
$notfranc4 = addslashes($_POST["notfranc4"]); 

//$math=addslashes($_POST["math"]); 
$notmath1 = addslashes($_POST["notmath1"]); 
$notmath2 = addslashes($_POST["notmath2"]); 
$notmath3 = addslashes($_POST["notmath3"]); 
$notmath4 = addslashes($_POST["notmath4"]); 

//$anglais=addslashes($_POST["anglais"]); 
$notanglais1 = addslashes($_POST["notanglais1"]); 
$notanglais2 = addslashes($_POST["notanglais2"]); 
$notanglais3 = addslashes($_POST["notanglais3"]); 
$notanglais4 = addslashes($_POST["notanglais4"]); 

//$scphys=addslashes($_POST["scphys"]); 
$notphys1 = addslashes($_POST["notphys1"]); 
$notphys2 = addslashes($_POST["notphys2"]); 
$notphys3 = addslashes($_POST["notphys3"]); 
$notphys4 = addslashes($_POST["notphys4"]); 

//$ortho=addslashes($_POST["ortho"]); 
$notortho1 = addslashes($_POST["notortho1"]); 
$notortho2 = addslashes($_POST["notortho2"]); 
$notortho3 = addslashes($_POST["notortho3"]); 
$notortho4 = addslashes($_POST["notortho4"]); 

//$histgeo=addslashes($_POST["histgeo"]); 
$histgeo1 = addslashes($_POST["histgeo1"]); 
$histgeo2 = addslashes($_POST["histgeo2"]); 
$histgeo3 = addslashes($_POST["histgeo3"]); 
$histgeo4 = addslashes($_POST["histgeo4"]); 

//$svt=addslashes($_POST["svt"]); 
$notsvt1 = addslashes($_POST["notsvt1"]); 
$notsvt2 = addslashes($_POST["notsvt2"]); 
$notsvt3 = addslashes($_POST["notsvt3"]); 
$notsvt4 = addslashes($_POST["notsvt4"]); 

$ResultatExamenCand = addslashes($_POST["ResultatExamenCand"]); 
$metier = addslashes($_POST["metier"]); 
$HandicapCand = addslashes($_POST["HandicapCand"]); 
$DoubleSelectCand = addslashes($_POST["DoubleSelectCand"]); 
$residenceParentCand = addslashes($_POST["residenceParentCand"]); 
$PersoneEnChargeCand = addslashes($_POST["PersoneEnChargeCand"]); 
$CelCand = addslashes($_POST["CelCand"]); 

$validation = array(); 
  //$count($matiere)
for($u=0;$u < $count($matiere);$u++) 

{ 

$matiere = $matiere[$u]; 


echo $requete = "INSERT INTO note (trimestre1 , trimestre2, trimestre3,moyenannuel)VALUES ('',"; 
switch ($matiere) { 
case "FRANCAIS": 

$parametres = $notfranc1."', '".$notfranc2."', '".$notfranc3."', '".$notfranc4."'"; 
break; 

case "MATHEMATIQUES": 

$parametres = $notmath1."', '".$notmath2."', '".$notmath3."', '".$notmath4."'"; 
break; 

case "ANGLAIS": 

$parametres = $notanglais1."', '".$notanglais2."', '".$notanglais3."', '".$notanglais4."'"; 
break; 

case "SCIENCES PHYSIQUES": 

$parametres = $notphys1."', '".$notphys2."', '".$notphys3."', '".$notphys4."'"; 
break; 

case "ORTHOGRAPHE": 

$parametres = $notortho1."', '".$notortho2."', '".$notortho3."', '".$notortho4."'"; 
break; 

case "HISTOIRE GEOGRAPHIE": 

$parametres = $histgeo1."', '".$histgeo2."', '".$histgeo3."', '".$histgeo4."'"; 
break; 

case "SVT": 

$parametres = $notsvt1."', '".$notsvt2."', '".$notsvt3."', '".$notsvt4."'"; 
break; 

} 

echo $tableau[1] = $requete .= $parametres.'")";'; 

echo $tableau[2] = $requete_info = "INSERT INTO candidat (ResultatExamenCand,metier,Handicap,DoubleSelectCand,residenceParentCand,PersoneEnChargeCand,CelCand )

VALUES (
'',
'$ResultatExamenCand',
'$metier',
'$Handicap',
'$DoubleSelectCand',
'$residenceParentCand',
'$PersoneEnChargeCand',
'$CelCand')"; 



function validiter_execution($requete_a_executer) 
{ 
return (mysql_query($requete_a_executer)) ? true : false; 
} 


$statut_execution_requete = ""; 
for($i=0;$i< count($tableau);$i++) 
{ 
$statut_execution_requete = validiter_execution($tableau[$i]); 
} 

$validation[$u] = $statut_execution_requete; 

} 

// if (in_array(false, $validation)) // validation a tester 
// 
// { 
// echo "<h3>l'inscription a ´chou´e</h3>"; 
// } 
// else 
// { 
// echo "<h3>l'inscription a été effectuée avec succès</h3>"; 
// } 

echo "<h3>l'inscription a été effectuée avec succès</h3>"; 
echo "<a href=\"Inscription.html\">Nouvelle inscription</a>"; 
echo "<br><a href=\"Consultation.php\">Consulter la liste</a>"; 
} 
?> 


Bonne programmation !
lundi 15 août 2011 à 14:46:34 | Re : problème d'insertion des données dans ma base de données en php

Mickael33480

Membre Club
Salut Bades,

Essaye d'ajouter un
Code PHP :
<? or die('Erreur SQL !'.$sql.mysql_error()) ?>
à la fin des tes requête SQL pour avoir les erreurs SQL qui remontes. Si tu en as, donne les ici.

Code PHP :
<? $req1 = mysql_query($sql1) or die('Erreur SQL !'.$sql.mysql_error()); ?>


Cette discussion est classée dans : php, données, post, echo, addslashes


Répondre à ce message

Sujets en rapport avec ce message

POST et formulaire [ par haklia ] Bonjour à tous,bon je vous expose mon petit soucis :j'ai créé un formulaire. Apres un clic sur le bouton Envoyer, les données sont transmises par POST Formulaire Html en Php [ par kiboumz ] Bonjour, j'ai eu petit bug que je n'arrive pas à résoudre lorsque je code ceci    echo '';    echo '';    echo '*Nom d\'utilisateur : &nbsp';  &nbs pb programme [ par pat65300 ] bonjour j ai un petit probleme avec ce programme.le programme:session-start();if (isset($-post['nom']&& isset ($-post['passe']{ $ nom = $-post['nom']; problème d'envoi avec un formulaire [ par darkwisk ] Salut à tous,Voici mon problème......2 pages PHP, la 1ère "clients.php" affiche un petit formulaire sous forme de liste déroulante avec les noms du ch probleme!!!! [ par nacer_1954 ] bonjour tout le monde j'ai envis de faire un seul fichier php qui va traiter plusieurs formulaires. donc j'ai fait une page ou j'ai mis  plusieurs  headers already sent by (output started .../veriflogin.php:9 [ par CyberMen30 ] J'ai un problème de headers que je ne comprends pas  :-(est-ce que quelqu'un vois l'erreur?session_start();?><cente recuperation de données [ par abdelmajid_daosabah ] bonjour tout le monde bon j'ai un projet en php/mysql et j'ai trouvé une difféculté pr la récuperation de certaines données a partir d'une boucle for; case a cocher php /mysql [ par yoyo77yo ] Bonjour !! et bonne année J'ai un probleme : j'ai repris le code de quélqu'un que j'ai payé mais par contre il n'est pas complet donc je voudrait Redirection après l’envoi mail [ par theyas ] Salut J'ai un problème sur mon formulaire d'envoi des mail .Je vais redirection sur la mem page de la formulaire et afficher une message javacript mai Syntaxe corecte [ par 4lman78 ] Voila mon formulaire :<INPUT type="text" name="t13


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

Photothèque

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,512 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales