IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Récupérer la valeur saisie dans un champ caché


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Par défaut Récupérer la valeur saisie dans un champ caché
    Bonjour voici le code de mon formulaire:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
     
     
    <? include("connexionphp.php");?>
     
     
     
    <html>
    <head><title>Gestion de flux &agrave; l'accueil</title>
    <!-- DEBUT DU SCRIPT DATE -->
    <script language="JavaScript">
    function VersionNavigateur(Netscape, Explorer)
    {  
    	if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||  (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    	 	return true;
    	else return false;
    }
    function Semaine()
    {
         	this[0] = "Dimanche";  
    	this[1] = "Lundi";
            this[2] = "Mardi";     
    	this[3] = "Mercredi";         
    	this[4] = "Jeudi";     
    	this[5] = "Vendredi";         
    	this[6] = "Samedi";       
    }
     
    function Mois()
    {          
    	this[0] = "Janvier";    
    	this[1] = "Février";          
    	this[2] = "Mars";       
    	this[3] = "Avril";          
    	this[4] = "Mai";        
    	this[5] = "Juin";          
    	this[6] = "Juillet";    
    	this[7] = "Août";         
    	this[8] = "Septembre";  
    	this[9] = "Octobre";          
    	this[10] = "Novembre";  
    	this[11] = "Décembre";           
    }
    today = new Date;
     
    function date()
    {
     
    	var semaine=new Semaine();
            var mois=new Mois();        
    	var myDate=new Date();       
    	annee = today.getFullYear();       
    	var result=semaine[myDate.getDay()]+" "+myDate.getDate()+" "+mois[myDate.getMonth()]+" "+annee;        
    	document.writeln(result);
    }
     
    function openWin( windowURL, windowName, windowFeatures ) 
    {                
    	return window.open( windowURL, windowName, windowFeatures ) ; 
    } 
     
     
    </script>
    <!-- FIN DU SCRIPT DATE -->
    </head>
     
    <body>
    <table border="0" cellpadding="3" cellspacing="0" width="100%">
      <tbody>  
    	<tr><td colspan="2"><img src="logosemacomplet.jpg"></td>				
     
    		<td colspan="3" align="center"><!-- DEBUT DU SCRIPT DATE-->
    	Aujourd'hui nous sommes le      <script language="JavaScript">date();</script><!-- FIN DU SCRIPT DATE-->
          <form action="EnregistreStatistique.php" method="post" name="Form1">
     
     
    	</td></tr>
     
    	<tr bgcolor="#92adba">
    		<td style="font-family: Arial; color: rgb(255, 255, 255); font-weight: bold;" align="center">SEXE</td>      
    		<td style="font-family: Arial; color: rgb(255, 255, 255); font-weight: bold;" align="center">AGE</td>
           		<td style="font-family: Arial; color: rgb(255, 255, 255); font-weight: bold;" align="center">LIEU</td>
    		<td style="font-family: Arial; color: rgb(255, 255, 255); font-weight: bold;" align="center">STATUT</td>
            	<td style="font-family: Arial; color: rgb(255, 255, 255); font-weight: bold;" align="center">SECTEUR</td>    
    	</tr>
     
    	<tr>
    	      	<td style="font-family: Arial; color: rgb(255, 255, 255);" bgcolor="#73005f">
    			HOMME : <input name="sexe" value="M" type="radio"><br>
    			FEMME : <input name="sexe" value="F" type="radio"> 
    		</td>     
    		<td style="font-family: Arial; color: rgb(255, 255, 255);" bgcolor="#1e3782"> 
    			+ 26 ANS : <input name="age" value="+26" type="radio"><br>
    			- 26 ANS : <input name="age" value="-26" type="radio"> 
    		</td>      
    		<td style="font-family: Arial; color: rgb(255, 255, 255);" bgcolor="#009bb4"> 
    			CAMSA : <input name="lieu" value="camsa" type="radio"><br>
    			AUTRE : <input name="lieu" value="non camsa" type="radio"> 
    		</td>     
    		<td style="font-family: Arial; color: rgb(255, 255, 255);" bgcolor="#a4d24b"> 
    			D.E : <input name="statut" value="de" type="radio"><br>
    			AUTRE : <input name="statut" value="nonde" type="radio"> 
    		</td>
     
    		<td align="center" bgcolor="#f6c51b">
    		      	<select name="secteur">
    			     	<option value="enseignement">Enseignement</option>     
    				<option value="metiers">M&eacute;tiers</option>      
    				<option value="emploi">Emploi</option>     
    				<option value="formation">Formation permanente</option>     
    				<option value="vie pratique">Vie pratique</option>
    			      	<option value="loisirs">Loisirs</option>      
    				<option value="vacances">Vacances</option>      
    				<option value="etranger">Dom Tom et &eacute;tranger</option>      
    				<option value="sports">Sports</option>      
    			</select>     
    		</td>    
    	</tr>  
    	<tr bgcolor="#cecece">      
    		<td colspan="5" align="center"> 
    			<input value="Envoyer" type="submit"> 
    		</td>    
    	</tr>  
     
    </form>
    </table>
    </tbody>
    <form action="CreeHistogramme.php" method="post" name="Form2">
    <table border="0" cellpadding="3" cellspacing="0" width="100%">
    	<tr>
    		<td align="center" valign="top">
     
    			<object border=5 width=490 height=380 NAME="name_iframe" data="CreeHistogramme.php" type="text/html">
    </object>
    		</td>
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input value="Voir les Stats" type="submit"> 
    		</td>    
    	</tr>
     
     
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="sexe"  type="hidden" value="<?php echo $_POST['sexe'] ?>"> 
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="age" value="<?php echo $_POST['age']; ?>" type="hidden">
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="lieu" value="<?php echo $_POST['lieu']; ?>" type="hidden">
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="statut" value="<?php echo $_POST['statut']; ?>" type="hidden">
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="secteur" value="<?php echo $_POST['secteur']; ?>" type="hidden">
    		</td>    
    	</tr>
     
    </table>
     
    </form>
    </body>
    </html>
    Tout fonctionne correctement sauf qu'ici:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <td colspan="5" align="center"> 
    			<input name="sexe"  type="hidden" value="<?php echo $_POST['sexe'] ?>"> 
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="age" value="<?php echo $_POST['age']; ?>" type="hidden">
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="lieu" value="<?php echo $_POST['lieu']; ?>" type="hidden">
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="statut" value="<?php echo $_POST['statut']; ?>" type="hidden">
    		</td>    
    	</tr>
    	<tr>	      
    		<td colspan="5" align="center"> 
    			<input name="secteur" value="<?php echo $_POST['secteur']; ?>" type="hidden">
    		</td>    
    	</tr>
    Je n'arrive pas à récupérer dans un champs caché les valeur saisies?

    Merci de me dire comment il faut faire, je suis débutante en php.

    Bonne journée!

    @+

  2. #2
    Membre éprouvé Avatar de julien.63
    Profil pro
    balayeur
    Inscrit en
    Décembre 2005
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Localisation : France, Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : balayeur

    Informations forums :
    Inscription : Décembre 2005
    Messages : 1 348
    Par défaut
    salut,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <?php echo $_POST['sexe'] ?>
    il te manque un ;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <?php echo $_POST['sexe']; ?>

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Par défaut
    Non, ça marche toujours pas.
    Je crois que ça vient des forms j'en ai deus et je veux récupérer les champs saisie de la première form dans la seconde.

    Merci de votre aide

  4. #4
    Membre confirmé
    Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    145
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Septembre 2005
    Messages : 145
    Par défaut
    Salut,

    les champs hidden et text fonctionnent pareil, passe ton champs en mode text regarde ce qu'il fait, si c'est bon tu peux le remettre en hidden

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Par défaut
    Ils sont vides les champs il ne me récupère rien du tout.
    J'ai deux forms c'est ça qui doit poser pb

  6. #6
    Membre confirmé
    Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    145
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Septembre 2005
    Messages : 145
    Par défaut
    peut etre que tout simplement ton $_POST ne renvoie rien utilise ca ala fin de ton code pour voir ce qu'il contient :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    	echo "######## POST ########<br>";
    	reset($_POST);
    	while (list($clef,$valeur)=each($_POST)) 
    	{
    	echo "   <B> ".$clef." : </b>".$valeur."<BR>";
    	}

Discussions similaires

  1. [MySQL] Récupérer les valeurs définies dans un champ ENUM
    Par Huntress dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 03/07/2010, 18h55
  2. récupérer la valeur saisie dans une combo box
    Par whitebird001 dans le forum MFC
    Réponses: 2
    Dernier message: 18/09/2008, 00h42
  3. Réponses: 10
    Dernier message: 07/05/2008, 22h19
  4. Réponses: 2
    Dernier message: 08/01/2007, 09h01
  5. Réponses: 2
    Dernier message: 11/12/2004, 21h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo