Stocker des valeurs dans ine table en php
sajodia
Messages postés
45
Statut
Membre
-
sajodia Messages postés 45 Statut Membre -
sajodia Messages postés 45 Statut Membre -
Bonjour,
Je n'arrive pas à insérer les informations de mon formulaire dans ma table:
je veux récupérer les informations saisies dans mon formulaire et les stocker dans ma table.Mais ça ne marche pas et je sais pas pourquoi.
aidez moi svp!!!!!!!!
Mon fichier html:
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
>
<html>
<!-- Date de création: 30/10/2008 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="Usager non enregistre">
<meta name="generator" content="WebExpert 6">
</head>
<body bgcolor="magenta">
<img src="images1.jpg" border="0" width="150" height="130" alt="">
<form action="add.php" method="post" enctype="multipart/form-data">
<TABLE border="3" ALIGN="center" height="536" width="472" bordercolor="teal" bordercolordark="teal" bordercolorlight="teal" style="background-color:white;">
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N°du formulaire:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° du formulaire " SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Marque :</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Marque" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N°inventaire CHU:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N°inventaire CHU" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N°serie:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° serie" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N° poste:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° poste" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N° UF:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° UF" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Nom_Prenom:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Nom_Prenom" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Secteur:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Secteur" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Service:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Service" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Localisation:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Localisation" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <font color="#336633">Type :</font></TD>
<TD width="328">
<p align="right">
<select name="Type" size="1">
<OPTION VALUE="DPM-9620">DPM-9620</OPTION>
<OPTION VALUE="Speech Mike">Speech Mike</OPTION>
<OPTION VALUE="Kit de transcription">Kit de transcription</OPTION>
</select></p>
</TD>
</TR>
<TR height="26">
<TD VALIGN="TOP" height="84" width="130"> <font color="#336633">Commentaires
: </font> </TD>
<TD height="84" width="328" align="right" valign="top">
<TEXTAREA NAME="Commentaires" ROWS="4" COLS="32" WRAP="virtual" STYLE="font-family:Arial; font-size:16px; background-color:white;" CLASS="cad">
Tapez ici vos commentaires</TEXTAREA>
</TD>
</TR>
<TR>
<TD COLSPAN=2 align="center">
<INPUT type="submit" value="Envoyer">
</TD>
</TR>
</TABLE>
</FORM>
<FORM>
<TABLE border="3" ALIGN="right"536" width="472" bordercolor="teal" bordercolordark="teal" bordercolorlight="teal" style="background-color:white;">
<TR height="26">
<TD>N°</TD>
<TD>
<INPUT type=text name="N°du formulaire">
</TD>
</TR>
<TR>
<TD>Unitéscommandés</TD>
<TD>
<INPUT type=text name="Marque">
</TD>
</TR>
<TR>
<TD>Nbre_d'entrées</TD>
<TD>
<INPUT type=text name="N° serie">
</TD>
</TR>
</TABLE>
</FORM>
</body>
</html>
Mon fichier Add.php
<?php /* Date de création: 25/11/2008 */ ?>
<html>
<body>
<?php
// On commence par récupérer les champs
if(isset($_POST['Numduformulaire'])) $nom=$_POST['Numduformulaire'];
else $Numduformulaire="";
if(isset($_POST['Marque'])) $prenom=$_POST['Marque'];
else $Marque="";
if(isset($_POST['Numinventaire'])) $email=$_POST['Numinventaire'];
else $NuminventaireCHU="";
if(isset($_POST['Numserie'])) $icq=$_POST['Numserie'];
else $Numserie="";
if(isset($_POST['Numposte'])) $titre=$_POST['Numposte'];
else $Numposte="";
if(isset($_POST['NumUF'])) $url=$_POST['NumUF'];
else $NumUF="";
if(isset($_POST['NomPrenom')) $url=$_POST['NomPrenom'];
else $NomPrenom="";
if(isset($_POST['Secteur'])) $url=$_POST['Secteur'];
else $Secteur="";
if(isset($_POST['Service'])) $url=$_POST['Service'];
else $Service="";
if(isset($_POST['Localisation'])) $url=$_POST['Localisation'];
else $Localisation="";
if(isset($_POST['Type'])) $url=$_POST['Type'];
else $Type="";
if(isset($_POST['Commentaires'])) $url=$_POST['Commentaires'];
else $Commentaires="";
// On vérifie si les champs sont vides
if(empty($Numinventaire) OR empty( $Numserie) OR empty($Numposte) OR empty($NumUF) OR empty($NomPrenom) OR empty($Secteur) OR empty($Service) OR empty($Localisation) OR empty($Type))
{
echo '<font color="red">Attention, seul le champs <b>Marque ,Numduformulaire , Commentaires</b> peut rester vide !</font>';
}
// Aucun champ n'est vide, on peut enregistrer dans la table
else
{
// connexion à la base
$db = mysql_connect('localhost', 'tata', 'tata') or die('Erreur de connexion '.mysql_error());
// sélection de la base
mysql_select_db('dicteenum',$db) or die('Erreur de selection '.mysql_error());
// on écrit la requête sql
$sql = "INSERT INTO dicteenum (Numduformulaire, Marque, Numinventaire, Numserie, Numposte, NumUF, Nom_Prenom, Secteur, Service, Localisation, Type, Commentaires)
VALUES ('$Numduformulaire', '$Marque', '$Numinventaire','$Numserie', '$Numposte', '$NumUF', '$nomPenom', '$Secteur', '$Service', '$Localisation', '$Type', '$Commentaires')";
// on insère les informations du formulaire dans la table
// on insère les informations du formulaire dans la table
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
// on affiche le résultat pour le visiteur
echo 'Vos infos on été ajoutées.';
mysql_close(); // on ferme la connexion
}
?>
Merci
Je n'arrive pas à insérer les informations de mon formulaire dans ma table:
je veux récupérer les informations saisies dans mon formulaire et les stocker dans ma table.Mais ça ne marche pas et je sais pas pourquoi.
aidez moi svp!!!!!!!!
Mon fichier html:
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
>
<html>
<!-- Date de création: 30/10/2008 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="Usager non enregistre">
<meta name="generator" content="WebExpert 6">
</head>
<body bgcolor="magenta">
<img src="images1.jpg" border="0" width="150" height="130" alt="">
<form action="add.php" method="post" enctype="multipart/form-data">
<TABLE border="3" ALIGN="center" height="536" width="472" bordercolor="teal" bordercolordark="teal" bordercolorlight="teal" style="background-color:white;">
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N°du formulaire:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° du formulaire " SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Marque :</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Marque" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N°inventaire CHU:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N°inventaire CHU" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N°serie:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° serie" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N° poste:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° poste" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">N° UF:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="N° UF" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Nom_Prenom:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Nom_Prenom" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Secteur:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Secteur" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Service:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Service" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <B> <font color="#336633"><span style="font-size:10pt;">Localisation:</span></font></B><font color="#336633"><span style="font-size:10pt;"> </span></font></TD>
<TD width="328">
<p align="right">
<INPUT TYPE="text" NAME="Localisation" SIZE="30"
STYLE="font-family:Arial; font-size:16px; background-color:white;"
CLASS="cad"> </p>
</TD>
</TR>
<TR height="26">
<TD width="130"> <font color="#336633">Type :</font></TD>
<TD width="328">
<p align="right">
<select name="Type" size="1">
<OPTION VALUE="DPM-9620">DPM-9620</OPTION>
<OPTION VALUE="Speech Mike">Speech Mike</OPTION>
<OPTION VALUE="Kit de transcription">Kit de transcription</OPTION>
</select></p>
</TD>
</TR>
<TR height="26">
<TD VALIGN="TOP" height="84" width="130"> <font color="#336633">Commentaires
: </font> </TD>
<TD height="84" width="328" align="right" valign="top">
<TEXTAREA NAME="Commentaires" ROWS="4" COLS="32" WRAP="virtual" STYLE="font-family:Arial; font-size:16px; background-color:white;" CLASS="cad">
Tapez ici vos commentaires</TEXTAREA>
</TD>
</TR>
<TR>
<TD COLSPAN=2 align="center">
<INPUT type="submit" value="Envoyer">
</TD>
</TR>
</TABLE>
</FORM>
<FORM>
<TABLE border="3" ALIGN="right"536" width="472" bordercolor="teal" bordercolordark="teal" bordercolorlight="teal" style="background-color:white;">
<TR height="26">
<TD>N°</TD>
<TD>
<INPUT type=text name="N°du formulaire">
</TD>
</TR>
<TR>
<TD>Unitéscommandés</TD>
<TD>
<INPUT type=text name="Marque">
</TD>
</TR>
<TR>
<TD>Nbre_d'entrées</TD>
<TD>
<INPUT type=text name="N° serie">
</TD>
</TR>
</TABLE>
</FORM>
</body>
</html>
Mon fichier Add.php
<?php /* Date de création: 25/11/2008 */ ?>
<html>
<body>
<?php
// On commence par récupérer les champs
if(isset($_POST['Numduformulaire'])) $nom=$_POST['Numduformulaire'];
else $Numduformulaire="";
if(isset($_POST['Marque'])) $prenom=$_POST['Marque'];
else $Marque="";
if(isset($_POST['Numinventaire'])) $email=$_POST['Numinventaire'];
else $NuminventaireCHU="";
if(isset($_POST['Numserie'])) $icq=$_POST['Numserie'];
else $Numserie="";
if(isset($_POST['Numposte'])) $titre=$_POST['Numposte'];
else $Numposte="";
if(isset($_POST['NumUF'])) $url=$_POST['NumUF'];
else $NumUF="";
if(isset($_POST['NomPrenom')) $url=$_POST['NomPrenom'];
else $NomPrenom="";
if(isset($_POST['Secteur'])) $url=$_POST['Secteur'];
else $Secteur="";
if(isset($_POST['Service'])) $url=$_POST['Service'];
else $Service="";
if(isset($_POST['Localisation'])) $url=$_POST['Localisation'];
else $Localisation="";
if(isset($_POST['Type'])) $url=$_POST['Type'];
else $Type="";
if(isset($_POST['Commentaires'])) $url=$_POST['Commentaires'];
else $Commentaires="";
// On vérifie si les champs sont vides
if(empty($Numinventaire) OR empty( $Numserie) OR empty($Numposte) OR empty($NumUF) OR empty($NomPrenom) OR empty($Secteur) OR empty($Service) OR empty($Localisation) OR empty($Type))
{
echo '<font color="red">Attention, seul le champs <b>Marque ,Numduformulaire , Commentaires</b> peut rester vide !</font>';
}
// Aucun champ n'est vide, on peut enregistrer dans la table
else
{
// connexion à la base
$db = mysql_connect('localhost', 'tata', 'tata') or die('Erreur de connexion '.mysql_error());
// sélection de la base
mysql_select_db('dicteenum',$db) or die('Erreur de selection '.mysql_error());
// on écrit la requête sql
$sql = "INSERT INTO dicteenum (Numduformulaire, Marque, Numinventaire, Numserie, Numposte, NumUF, Nom_Prenom, Secteur, Service, Localisation, Type, Commentaires)
VALUES ('$Numduformulaire', '$Marque', '$Numinventaire','$Numserie', '$Numposte', '$NumUF', '$nomPenom', '$Secteur', '$Service', '$Localisation', '$Type', '$Commentaires')";
// on insère les informations du formulaire dans la table
// on insère les informations du formulaire dans la table
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
// on affiche le résultat pour le visiteur
echo 'Vos infos on été ajoutées.';
mysql_close(); // on ferme la connexion
}
?>
Merci
A voir également:
- Stocker des valeurs dans ine table en php
- Table des matières word - Guide
- Table ascii - Guide
- Table des caractères - Guide
- Pourquoi mon ine a changé ✓ - Forum Études / Formation High-Tech
- Easy php - Télécharger - Divers Web & Internet