Précédent   Forum des professionnels en informatique > PHP > Langage > Formulaires
Formulaires Forum d'entraide sur les formulaires avec PHP. Avant de poster -> FAQ formulaires, Cours de formulaires et Sources de formulaires
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 20/06/2008, 14h39   #1
Membre du Club
 
Inscription : septembre 2007
Messages : 424
Détails du profil
Informations forums :
Inscription : septembre 2007
Messages : 424
Points : 41
Points : 41
Par défaut Formulaire d'insertion et upload

bonjour, j'ai crée une formulaire qui fais l'insertion des information dans la BD mais il y a un champs qui pas ajouter si un champ qui j'ai fait l'upload d'une photo le code de la formulaire est
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
          <table width="465" align="center">
            <tr valign="baseline">
              <td width="136" height="34" align="right" nowrap="nowrap"><strong>Code enseignant:</strong></td>
              <td width="317"><input type="text" name="code" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Code groupe<br /> 
              de recherche:</strong></td>
              <td><input type="text" name="code_gr" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Nom:</strong></td>
              <td><input type="text" name="nom" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Prenom:</strong></td>
              <td><input type="text" name="prenom" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Grade:</strong></td>
              <td><input type="text" name="grade" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Tele:</strong></td>
              <td><input type="text" name="tele" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Fax:</strong></td>
              <td><input type="text" name="fax" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Adresse:</strong></td>
              <td><input type="text" name="adresse" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Email:</strong></td>
              <td><input type="text" name="email" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Photo:</strong></td>
              <td><label>
                <input type="file" name="photo" id="photo" />
                <?
// Taille max des fichiers (octets)
$MFS=10000000024;
// Répertoire de stockage
$rep="upload/";
 
if(isset($_FILES['userfile'])) {
if($_FILES['userfile']['size']>0) {
   $savefile= $rep.$_FILES['userfile']['name'];
   $temp = $_FILES['userfile']['tmp_name'];
   if (move_uploaded_file($temp, $savefile)) { ?>
      <b>Votre fichier a bien été enregistré !</b>
<BR>Nom : <?echo $_FILES['userfile']['name'];?>
<BR>Taille : <?echo $_FILES['userfile']['size'];?> o
<BR>Type : <?echo $_FILES['userfile']['type'];?>
<?   } else { ?>
      <b>Erreur d'enregistrement !</b>
   <? }
 
} else { ?>
   <b>Trop gros fichier !</b>
   <i>( <? echo $MFS;?> octets max.)</i>
<? } 
} ?>
              </label></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Service/membre:</strong></td>
              <td><input type="text" name="service_membre" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right" valign="top"><strong>Diplome:</strong></td>
              <td><textarea name="diplome" cols="50" rows="5"></textarea>              </td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right" valign="top"><p><strong>Enseignament et</strong><strong><br />
                cours récents:</strong></p>
              </td>
              <td><textarea name="Enseignament_cours" cols="50" rows="5"></textarea>              </td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">&nbsp;</td>
              <td><input type="submit" value="Insérer" /></td>
            </tr>
          </table>
          <input type="hidden" name="MM_insert" value="form1" />
      </form>
touts les champs insérer sauf le champ 'photo' , je sais qu'il y a une erreur dans la recupiration de chemin puisque le code de la recupiration est
Code :
GetSQLValueString($_POST['photo'], "text"),
et la requete d'insertion
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO enseignant (code, code_gr, nom, prenom, grade, tele, fax, adresse, email, photo, service_membre, diplome, Enseignament_cours) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['code'], "text"),
                       GetSQLValueString($_POST['code_gr'], "int"),
                       GetSQLValueString($_POST['nom'], "text"),
                       GetSQLValueString($_POST['prenom'], "text"),
                       GetSQLValueString($_POST['grade'], "text"),
                       GetSQLValueString($_POST['tele'], "int"),
                       GetSQLValueString($_POST['fax'], "int"),
                       GetSQLValueString($_POST['adresse'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['photo'], "text"),
                       GetSQLValueString($_POST['service_membre'], "text"),
                       GetSQLValueString($_POST['diplome'], "text"),
                       GetSQLValueString($_POST['Enseignament_cours'], "text"));
comment pui-je recupirer le chemin de la photo
dreamVIG est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/06/2008, 17h37   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 383
Points : 16 383
Le chemin de la photo tu le connais déjà puisque c'est toi qui le defini :

Je cite ton code :
Code :
1
2
$rep="upload/";
$savefile= $rep.$_FILES['userfile']['name'];
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/06/2008, 18h41   #3
Membre confirmé
 
Avatar de juliens9
 
Directeur technique
Inscription : mars 2007
Messages : 192
Détails du profil
Informations personnelles :
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Directeur technique

Informations forums :
Inscription : mars 2007
Messages : 192
Points : 220
Points : 220
Le chemin contient deux composantes :

- le fichier "upload/blabla"
- le fichier dans lequel se trouve ton script,

Si ton script se trouve dans /home/web/

ton fichier se trouvera alors dans /home/web/upload/monfichier
juliens9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/06/2008, 00h13   #4
Membre du Club
 
Inscription : septembre 2007
Messages : 424
Détails du profil
Informations forums :
Inscription : septembre 2007
Messages : 424
Points : 41
Points : 41
bonjour,
je sais que les photo est dans le répertoire 'upload' mais comment je dis ça dans la requete 'insertinto' au même temps que l'upload
dreamVIG est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/06/2008, 18h02   #5
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 383
Points : 16 383
Je t'ai repondu, dans ton champ photo tu fais inserer la valeur
$_FILES['userfile']['name'];
et pas $_POST['photo']
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/06/2008, 18h20   #6
Membre du Club
 
Inscription : septembre 2007
Messages : 424
Détails du profil
Informations forums :
Inscription : septembre 2007
Messages : 424
Points : 41
Points : 41
j'ai essayé mais l'insersion ne faite pas meme la phto n'uploader pas a la repertoire avans elle fonctionne mais maintenant la formulaire ne marche pas partout
le code de la formulaire est
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
          <table width="465" align="center">
            <tr valign="baseline">
              <td width="136" height="34" align="right" nowrap="nowrap"><strong>Code enseignant:</strong></td>
              <td width="317"><input type="text" name="code" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Code groupe<br /> 
              de recherche:</strong></td>
              <td><input type="text" name="code_gr" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Nom:</strong></td>
              <td><input type="text" name="nom" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Prenom:</strong></td>
              <td><input type="text" name="prenom" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Grade:</strong></td>
              <td><input type="text" name="grade" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Tele:</strong></td>
              <td><input type="text" name="tele" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Fax:</strong></td>
              <td><input type="text" name="fax" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Adresse:</strong></td>
              <td><input type="text" name="adresse" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Email:</strong></td>
              <td><input type="text" name="email" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Photo:</strong></td>
              <td><label>
                <input type="file" name="userfile" id="userfile" />
                <?
// Taille max des fichiers (octets)
$MFS=10000000024;
// Répertoire de stockage
$rep="upload/";
 
if(isset($_FILES['userfile'])) {
if($_FILES['userfile']['size']>0) {
   $savefile= $rep.$_FILES['userfile']['name'];
   $temp = $_FILES['userfile']['tmp_name'];
   if (move_uploaded_file($temp, $savefile)) { ?>
      <b>Votre fichier a bien été enregistré !</b>
<BR>Nom : <?echo $_FILES['userfile']['name'];?>
<BR>Taille : <?echo $_FILES['userfile']['size'];?> o
<BR>Type : <?echo $_FILES['userfile']['type'];?>
<?   } else { ?>
      <b>Erreur d'enregistrement !</b>
   <? }
 
} else { ?>
   <b>Trop gros fichier !</b>
   <i>( <? echo $MFS;?> octets max.)</i>
<? } 
} ?>
              </label></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Service/membre:</strong></td>
              <td><input type="text" name="service_membre" value="" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right" valign="top"><strong>Diplome:</strong></td>
              <td><textarea name="diplome" cols="50" rows="5"></textarea>              </td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right" valign="top"><p><strong>Enseignament et</strong><strong><br />
                cours récents:</strong></p>
              </td>
              <td><textarea name="Enseignament_cours" cols="50" rows="5"></textarea>              </td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">&nbsp;</td>
              <td><input type="submit" value="Insérer" /></td>
            </tr>
          </table>
          <input type="hidden" name="MM_insert" value="form1" />
      </form>
et le code qui fait l'insertion est
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO enseignant (code, code_gr, nom, prenom, grade, tele, fax, adresse, email, photo, service_membre, diplome, Enseignament_cours) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['code'], "text"),
                       GetSQLValueString($_POST['code_gr'], "int"),
                       GetSQLValueString($_POST['nom'], "text"),
                       GetSQLValueString($_POST['prenom'], "text"),
                       GetSQLValueString($_POST['grade'], "text"),
                       GetSQLValueString($_POST['tele'], "int"),
                       GetSQLValueString($_POST['fax'], "int"),
                       GetSQLValueString($_POST['adresse'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_FILES['userfile']['name'], "file"),
                       GetSQLValueString($_POST['service_membre'], "text"),
                       GetSQLValueString($_POST['diplome'], "text"),
                       GetSQLValueString($_POST['Enseignament_cours'], "text"));
 
  mysql_select_db($database_informatique, $informatique);
  $Result1 = mysql_query($insertSQL, $informatique) or die(mysql_error());
 
  $insertGoTo = "../../reussite.html";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
dreamVIG est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/06/2008, 19h53   #7
Membre confirmé
 
Avatar de juliens9
 
Directeur technique
Inscription : mars 2007
Messages : 192
Détails du profil
Informations personnelles :
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Directeur technique

Informations forums :
Inscription : mars 2007
Messages : 192
Points : 220
Points : 220
Tu peux parler plus francais, car la j'ai du mal a saisir le sens de ta phrase et de ton probleme....
juliens9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 02h56.


 
 
 
 
Partenaires

Hébergement Web