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 21/01/2008, 18h22   #1
Membre régulier
 
Inscription : octobre 2007
Messages : 286
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 286
Points : 96
Points : 96
Par défaut Rechargement non fait

Bonsoir, j'aurai aimé savoir comment je fais pour que les données de mon formulaire soit renotées dans les champs apropriés sachant qu'il a deja ete remplis auparavant. J'ai essayé avec ce code
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
<?php
}
elseif(mysql_num_rows($compte) != 0) {
mysql_close($connexion); 
?>
<!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>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<title>...</title>
				<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
				</head>
				<body>
					<div id="corps">
						Ce pseudo existe déjà.<br />
						<a href="formulaire test.php?&nom=<?php echo $nom; ?>&prenom=<?php echo $prenom; ?>&age=<?php echo $age; ?>&mail=<?php echo $mail; ?>" title="inscription">OK</a>
					</div>
				  <div id="pied">
            <?php include("date.php"); ?>
          </div>
        </body>
				</html>
Mais les données ne se remettent pas.
kev484 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 18h29   #2
Membre du Club
 
Inscription : mai 2006
Messages : 45
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : mai 2006
Messages : 45
Points : 41
Points : 41
salut,
je crois que l'erreur vient du lien:
Code :
1
2
Ce pseudo existe déjà.<br />
<a href="formulaire test.php?&nom=<?php echo $nom; ?>&prenom=<?php echo $prenom; ?>&age=<?php echo $age; ?>&mail=<?php echo $mail; ?>" title="inscription">OK</a>
après le ? met directement le premier variable et remplace & par leur code html &amp;
mbounou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 18h41   #3
Membre régulier
 
Inscription : octobre 2007
Messages : 286
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 286
Points : 96
Points : 96
Meme en mettant ceci :
Code :
<a href="formulaire test.php?nom=<?php echo $nom; ?>&amp;prenom=<?php echo $prenom; ?>&amp;age=<?php echo $age; ?>&amp;mail=<?php echo $mail; ?>" title="inscription">OK</a>
ma page n'a pas les données deja renseignées. Voulez-vous tout mon code?
kev484 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 18h46   #4
Membre du Club
 
Inscription : mai 2006
Messages : 45
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : mai 2006
Messages : 45
Points : 41
Points : 41
tu dois encore metre dans les champs l'attribut
Code :
value="<?php echo$_GET['variable'];?>"
mbounou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 18h48   #5
Membre régulier
 
Inscription : octobre 2007
Messages : 286
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 286
Points : 96
Points : 96
Ok mais il ne faut pas alors qu'au debut je dise qu'il n'y a rien?
Apparament si car losrque j'ouvre ma page il me met dans mes champs :
Code :
<br /><b>Notice</b>:  Undefined index:  nom in <b>c:\program files\easyphp1-8\www\new projet\formulaire test.php</b> on line <b>39</b><br />
J'ai mis cela :
Code :
1
2
3
4
5
6
7
8
  <p>
    <label for="nom">Nom : </label>
    <input type="text" name="nom" id="nom" value="<?php echo$_GET['nom'];?>"/>
  </p>  
  <p>
    <label for="prenom">Prénom : </label>
    <input type="text" name="prenom" id="prenom" value="<?php echo$_GET['prenom'];?>"/>
  </p>
kev484 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 19h00   #6
Membre du Club
 
Inscription : mai 2006
Messages : 45
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : mai 2006
Messages : 45
Points : 41
Points : 41
ok test d'abor si les variables exist a l'ade de exemple:
Code :
1
2
if(isset($_GET['nom'] && !empty($_GET['nom']))
$nom=$_GET['nom'];
comme tu peut utiliser

import_request_variables("G","GET_");
mbounou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 19h01   #7
Membre régulier
 
Inscription : octobre 2007
Messages : 286
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 286
Points : 96
Points : 96
Ba j'ai deja fait tout cela. Voila tout mon code :
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
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
$connexion = mysql_pconnect("localhost","root","");
mysql_select_db("enregistrement",$connexion);
if (!$connexion){
echo "La connexion ne peut pas s'etablir"; exit;
}
if (!mysql_select_db("enregistrement",$connexion)){
echo "La base est introuvable"; exit;
}
if(isset($_POST['login']) && !empty($_POST['login'])){
$login = mysql_real_escape_string(htmlspecialchars($_POST['login']));
}
if(isset($_POST['mdp']) && !empty($_POST['mdp'])){
$pwd = mysql_real_escape_string(htmlspecialchars($_POST['mdp']));
}
if(isset($_POST['mdp2']) && !empty($_POST['mdp2'])){
$pwd2 = mysql_real_escape_string(htmlspecialchars($_POST['mdp2']));
}
if(isset($_POST['sexe']) && !empty($_POST['sexe'])){
$sexe = mysql_real_escape_string(htmlspecialchars($_POST['sexe']));
}
if(isset($_POST['nom']) && !empty($_POST['nom'])){
$nom = mysql_real_escape_string(htmlspecialchars($_POST['nom']));
}
if(isset($_POST['prenom']) && !empty($_POST['prenom'])){
$prenom = mysql_real_escape_string(htmlspecialchars($_POST['prenom']));
}
if(isset($_POST['age']) && !empty($_POST['age'])){
$age = mysql_real_escape_string($_POST['age']);
}
if(isset($_POST['mail']) && !empty($_POST['mail'])){
$mail = mysql_real_escape_string(htmlspecialchars($_POST['mail']));
}
$compte = mysql_query("SELECT * FROM enregistrement WHERE login='$login'") or die(mysql_error());
$regex = "/^[-+.\w]{1,64}@[-.\w]{1,64}\.[-.\w]{2,6}$/i";
 
if (preg_match($regex, $mail)) {
  if(mysql_num_rows($compte) == 0) 
  {
    mysql_query("INSERT INTO enregistrement(login, mdp, sexe, nom, prenom, age, mail) VALUES('$login', '$pwd', '$sexe', '$nom', '$prenom', '$age', '$mail')", $connexion) or die(mysql_error());
    $headers = "From: ... <kev484@hotmail.com>\r\n";
    $headers .= 'Content-type: text/html; charset=ISO-8859-1'."\n";
    $headers .= "Reply-To: kev484@hotmail.com\r\n";
    $sujet = "Site de Kevin - Confirmation d'inscription";
    $message = "<html>";
    $message .= "<p>Bonjour,<br /><br />";
    $message .= "Merci de vous ete inscrit sur le site de .... ! Pour acceder au site cliquez ici. <br />" ;
    $message .= "A bientot sur notre site.<br /><br />Kevin</p>";
    $message .= "</html>";
    mail($mail, $sujet, $message, $headers);
 
mysql_close($connexion); 
?>
				<!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>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>...</title>
					<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
				</head>
				<body>
					<div id="corps">
						Votre inscription a bien été effectué.<br />
						<a href="#" title="ok">Ok</a>
					</div>
				  <div id="pied">
            <?php include("date.php"); ?>
          </div>
				</body>
				</html>
<?php
}
elseif(mysql_num_rows($compte) != 0) {
mysql_close($connexion); 
?>
<!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>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<title>...</title>
				<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
				</head>
				<body>
					<div id="corps">
						Ce pseudo existe déjà.<br />
						<a href="formulaire test.php?nom=<?php echo $nom; ?>&amp;prenom=<?php echo $prenom; ?>&amp;age=<?php echo $age; ?>&amp;mail=<?php echo $mail; ?>" title="inscription">OK</a>
					</div>
				  <div id="pied">
            <?php include("date.php"); ?>
          </div>
        </body>
				</html>
<?php		
}
}
else{
echo "L'adresse mail n'est pas valide.";
}  
?>
kev484 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 19h16   #8
Membre du Club
 
Inscription : mai 2006
Messages : 45
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : mai 2006
Messages : 45
Points : 41
Points : 41
tu dois metre la meme chose dans la page du formulaire.
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
 
if(isset($_GET['login']) && !empty($_GET['login'])){
$login = mysql_real_escape_string(htmlspecialchars($_GET['login']));
}
if(isset($_GET['mdp']) && !empty($_GET['mdp'])){
$pwd = mysql_real_escape_string(htmlspecialchars($_GET['mdp']));
}
if(isset($_GET['mdp2']) && !empty($_GET['mdp2'])){
$pwd2 = mysql_real_escape_string(htmlspecialchars($_GET['mdp2']));
}
if(isset($_GET['sexe']) && !empty($_GET['sexe'])){
$sexe = mysql_real_escape_string(htmlspecialchars($_GET['sexe']));
}
if(isset($_GET['nom']) && !empty($_GET['nom'])){
$nom = mysql_real_escape_string(htmlspecialchars($_GET['nom']));
}
if(isset($_GET['prenom']) && !empty($_GET['prenom'])){
$prenom = mysql_real_escape_string(htmlspecialchars($_GET['prenom']));
}
if(isset($_GET['age']) && !empty($_GET['age'])){
$age = mysql_real_escape_string($_GET['age']);
}
if(isset($_GET['mail']) && !empty($_GET['mail'])){
$mail = mysql_real_escape_string(htmlspecialchars($_GET['mail']));
}
mbounou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 19h49   #9
Membre régulier
 
Inscription : octobre 2007
Messages : 286
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 286
Points : 96
Points : 96
Voila donc mon code html :
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
91
92
93
<?php 
if(isset($_GET['login']) && !empty($_GET['login'])){
$login = mysql_real_escape_string(htmlspecialchars($_GET['login']));
}
if(isset($_GET['mdp']) && !empty($_GET['mdp'])){
$pwd = mysql_real_escape_string(htmlspecialchars($_GET['mdp']));
}
if(isset($_GET['mdp2']) && !empty($_GET['mdp2'])){
$pwd2 = mysql_real_escape_string(htmlspecialchars($_GET['mdp2']));
}
if(isset($_GET['sexe']) && !empty($_GET['sexe'])){
$sexe = mysql_real_escape_string(htmlspecialchars($_GET['sexe']));
}
if(isset($_GET['nom']) && !empty($_GET['nom'])){
$nom = mysql_real_escape_string(htmlspecialchars($_GET['nom']));
}
if(isset($_GET['prenom']) && !empty($_GET['prenom'])){
$prenom = mysql_real_escape_string(htmlspecialchars($_GET['prenom']));
}
if(isset($_GET['age']) && !empty($_GET['age'])){
$age = mysql_real_escape_string($_GET['age']);
}
if(isset($_GET['mail']) && !empty($_GET['mail'])){
$mail = mysql_real_escape_string(htmlspecialchars($_GET['mail']));
}
?>
<!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">
<head>
  <title>Formulaire d'inscription</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="style/formulaire.css"  type="text/css" />
  <script src="formulaire.js" type="text/javascript"></script>
</head> 
<body onload="window.defaultStatus='Vous etes actuellement sur le formulaire';sport_update()">
<form action="formulaire.php" enctype="multipart/form-data" method="post" onsubmit="return verif();">
<fieldset>
  <legend>Identification pour se connecter</legend>
  <p>
    <label for="login" id="label_login" >Choisissez un login : </label>
    <input type="text" name="login" id="login" onfocus="italic();" onblur="normal()"  />
  </p>
  <p>
    <label for="mdp">Choisissez un mot de passe : </label>
    <input type="password" name="mdp" id="mdp"/>
  </p>
  <p>
    <label for="mdp1">Confirmez votre mot de passe : </label>
    <input type="password" name="mdp1" id="mdp1"/>
  </p>
</fieldset>
<fieldset>
  <legend>Renseignements personnels</legend>
  <div> Votre situation :
    <input type="radio" name="sexe" value="monsieur" checked="checked"/>
    <label for="Monsieur">Mr</label>
    <input type="radio" name="sexe" value="madame"/>
    <label for="Madame">Mme</label>
    <input type="radio" name="sexe" value="mademoiselle"/>
    <label for="Mademoiselle">M lle</label>
  </div>
  <p>
    <label for="nom">Nom : </label>
    <input type="text" name="nom" id="nom" value="<?php echo $_GET['nom'];?>"/>
  </p>  
  <p>
    <label for="prenom">Prénom : </label>
    <input type="text" name="prenom" id="prenom" value="<?php echo $_GET['prenom'];?>"/>
  </p>      
  <p>
    <label for="age">Age : </label>
    <select id="age" name="age">
      <option value="-10">Moins de 10 ans</option>
		  <option value="10-19">De 10 à 19 ans</option>
		  <option value="20-29">De 20 à 29 ans</option>
		  <option value="30-39">De 30 à 39 ans</option>
		  <option value="40-49">De 40 à 49 ans</option>
		  <option value="50-59">De 50 à 59 ans</option>
		  <option value="+60">Plus de 60 ans</option>
		</select>
  </p>
  <p>
    <label for="mail">Indiquez votre mail : </label>
    <input type="text" name="mail" id="mail" value="<?php echo $_GET['mail'];?>"/>
  </p>
</fieldset>
<p><br /><br /></p>
<p><input type="submit" name="valide" value="Valider"/></p>
</form>
<?php include("date.php"); ?>
</body>
</html>
Et mon 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
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
$connexion = mysql_pconnect("localhost","root","");
mysql_select_db("enregistrement",$connexion);
if (!$connexion){
echo "La connexion ne peut pas s'etablir"; exit;
}
if (!mysql_select_db("enregistrement",$connexion)){
echo "La base est introuvable"; exit;
}
if(isset($_POST['login']) && !empty($_POST['login'])){
$login = mysql_real_escape_string(htmlspecialchars($_POST['login']));
}
if(isset($_POST['mdp']) && !empty($_POST['mdp'])){
$pwd = mysql_real_escape_string(htmlspecialchars($_POST['mdp']));
}
if(isset($_POST['mdp2']) && !empty($_POST['mdp2'])){
$pwd2 = mysql_real_escape_string(htmlspecialchars($_POST['mdp2']));
}
if(isset($_POST['sexe']) && !empty($_POST['sexe'])){
$sexe = mysql_real_escape_string(htmlspecialchars($_POST['sexe']));
}
if(isset($_POST['nom']) && !empty($_POST['nom'])){
$nom = mysql_real_escape_string(htmlspecialchars($_POST['nom']));
}
if(isset($_POST['prenom']) && !empty($_POST['prenom'])){
$prenom = mysql_real_escape_string(htmlspecialchars($_POST['prenom']));
}
if(isset($_POST['age']) && !empty($_POST['age'])){
$age = mysql_real_escape_string($_POST['age']);
}
if(isset($_POST['mail']) && !empty($_POST['mail'])){
$mail = mysql_real_escape_string(htmlspecialchars($_POST['mail']));
}
$compte = mysql_query("SELECT * FROM enregistrement WHERE login='$login'") or die(mysql_error());
$regex = "/^[-+.\w]{1,64}@[-.\w]{1,64}\.[-.\w]{2,6}$/i";
 
if (preg_match($regex, $mail)) {
  if(mysql_num_rows($compte) == 0) 
  {
    mysql_query("INSERT INTO enregistrement(login, mdp, sexe, nom, prenom, age, mail) VALUES('$login', '$pwd', '$sexe', '$nom', '$prenom', '$age', '$mail')", $connexion) or die(mysql_error());
    $headers = "From: ... <kev484@hotmail.com>\r\n";
    $headers .= 'Content-type: text/html; charset=ISO-8859-1'."\n";
    $headers .= "Reply-To: kev484@hotmail.com\r\n";
    $sujet = "Site de Kevin - Confirmation d'inscription";
    $message = "<html>";
    $message .= "<p>Bonjour,<br /><br />";
    $message .= "Merci de vous ete inscrit sur le site de .... ! Pour acceder au site cliquez ici. <br />" ;
    $message .= "A bientot sur notre site.<br /><br />Kevin</p>";
    $message .= "</html>";
    mail($mail, $sujet, $message, $headers);
 
mysql_close($connexion); 
?>
				<!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>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>...</title>
					<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
				</head>
				<body>
					<div id="corps">
						Votre inscription a bien été effectué.<br />
						<a href="#" title="ok">Ok</a>
					</div>
				  <div id="pied">
            <?php include("date.php"); ?>
          </div>
				</body>
				</html>
<?php
}
elseif(mysql_num_rows($compte) != 0) {
mysql_close($connexion); 
?>
<!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>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<title>...</title>
				<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
				</head>
				<body>
					<div id="corps">
						Ce pseudo existe déjà.<br />
						<a href="formulaire test.php?nom=<?php echo $nom; ?>&amp;prenom=<?php echo $prenom; ?>&amp;age=<?php echo $age; ?>&amp;mail=<?php echo $mail; ?>" title="inscription">OK</a>
					</div>
				  <div id="pied">
            <?php include("date.php"); ?>
          </div>
        </body>
				</html>
<?php		
}
}
else{
echo "L'adresse mail n'est pas valide.";
}  
?>
Il ne fonctionne toujours pas.
kev484 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/01/2008, 20h03   #10
Membre régulier
 
Inscription : octobre 2007
Messages : 286
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 286
Points : 96
Points : 96
En fete si tout fonctionne. Je le testais en local c'est donc pour cela que l'erreur s'affichait.
Merci
kev484 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 05h55.


 
 
 
 
Partenaires

Hébergement Web