Précédent   Forum du club des développeurs et IT Pro > PHP > Langage > Sessions
Sessions Forum d'entraide sur les sessions avec PHP. Avant de poster -> FAQ sessions, Cours sessions et Sources sécurité
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 07/01/2013, 18h31   #1
coppin
Invité de passage
 
Inscription : décembre 2012
Messages : 14
Détails du profil
Informations forums :
Inscription : décembre 2012
Messages : 14
Points : 0
Points : 0
Par défaut compteur dans une session

J'ai 2 page php l'une pour faire une selection globale mais qui avant de lancer la recherche via une troisieme page php peut faire appel à la deuxième pour remplir les case "code postal".

Cela marche bien pour la première case mais je trouve pas le truc pour qu'à chaque appel il complète la case suivante. Pour l'instant il rempli tjs la première

1ere page qui appelle via le lien pour code postal "selectioncp.php"

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
<?php
// On démarre la session AVANT d'écrire du code HTML
session_start();
 
?>
 
 
 
 
<?php
$cp1 = "";
$cp2 = "";
$cp3 = "";
$cp4 = "";
 
 
				if (isset($_POST['codepostal']))
				{
					$cp1 =htmlspecialchars($_POST['codepostal']);
 
 
}
?>
<table>
<form method="post" action="resultat2.php" enctype="multipart/form-data" onsubmit="return checkform(this)">
 
 
<td align=center><b> Rechercher selon les critères suivant :</b></td>
 
<tr><td>Pays</td>         
<td><SELECT name="pays" id ="pays">
<option value="belgique">Belgique</option>
<option value="france">France</option>
<option value="luxembourg">Luxembourg</option>
 
</td> 
	</select>       
 
<tr><td>Type de Commerce </td>         
<td><SELECT name="typedecommerce" id ="typedecommerce">
<option value="librairie">Librairie</option>
<option value="commerce">Commerce</option></td> 
	</select>       
 
<tr><td>Rérion</td>         
<td><SELECT name="region" id ="region">
<option value="brabantwallon">Brabant Wallon</option>
<option value="bruxelles">Bruxelles</option></td> 
	</select>
 
<tr><td>Code Postal</td> 
<td><input name="cp1" size="4" type="texte" id="cp1" value="<?php echo $cp1;?>" >
<input name="cp2" size="4" type="texte" id="cp2" value="<?php echo $cp2;?>">
<input name="cp3" size="4" type="texte" id="cp3" value="<?php echo $cp3;?>">
<input name="cp4" size="4" type="texte" id="cp4" value="<?php echo $cp4;?>">
 <tr><td><a href="selectioncp.php" target="_self">Aide recherche codes postaux
 
</td>
 
<tr><td>Prix Minimum</td>
<td><input name="prixmin" type="texte" id="prixmin" value ="0"><td>
 
<tr><td>Prix Maximum</td>
<td><input name="prixmax" type="texte" id="prixmax"><td>
 
<tr><td align=center><b> Afficher selon les Critères suivants :</b></td>
 
 
<tr><td>Trier suivant :</td>
<td><select name="selection1"  id="selection1">
<OPTION value ="prix">Prix</option>
<OPTION value ="cp">Code Postal</option>
<OPTION value ="photo">Avec photos</option>
<OPTION value ="dateparution">Date de parution</option></td>
	</select>
 
<tr><td>Trier suivant :</td>
<td><select name="selection2"  id="selection2">
<OPTION value ="prix">Prix</option>
<OPTION value ="cp">Code Postal</option>
<OPTION value ="photo">Avec photos</option>
<OPTION value ="dateparution">Date de parution</option></td>
	</select>	
 
 
 
 
<tr><td><input type="submit" name="go" value="Validez"></td></tr>
 
</table>

2ieme page "selectioncp.php" qui retourne vers la première après selection


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
<?php
// On démarre la session AVANT d'écrire du code HTML
session_start();
 $_SESSION['cp'] = '';
 $_SESSION['nombre'] = '';
?>
 
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
        <title>selection</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <style type="text/css">
    form
    {
        text-align:center;
    }
    </style>
    <body> 
 
 
 <FORM method="post" action="recherche.php">
 
 
    <label for="codepostal">Code Postal</label>
<SELECT name="codepostal" size="1" id="codepostal" onchange="this.form.submit()" >   
 
<?php
 
$cp="";
 
// Connexion à la base de données
try
{
	$bdd = new PDO('mysql:host=localhost;dbname=prospection_email', 'root', '')or die(print_r($bdd->errorInfo()));
 
}
catch(Exception $e)
{
        die('Erreur : '.$e->getMessage());
}
 
 
$reponse = $bdd->query('SELECT zip, name FROM cities ORDER BY zip ASC ')or die(print_r($bdd->errorInfo()));
 
 
//  par htmlspecialchars)
while ($donnees = $reponse->fetch())
	{
?>
<option value="<?php echo $donnees['zip'];?>"><?php echo $donnees['zip'];?>-<?php echo $donnees['name'];?> </option>
 
<?php
	}
 
$reponse->closeCursor();
 
?>
 
 
 
 
 
</SELECT>
<input type="submit">
</FORM>
</body>
 
</html>
peut-être possible de tout mettre dans une page ?

Merci d'avance
coppin est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 21h15.


 
 
 
 
Partenaires

Hébergement Web