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 17/04/2007, 17h38   #1
Candidat au titre de Membre du Club
 
Inscription : juin 2006
Messages : 92
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 92
Points : 12
Points : 12
Par défaut Formulaire d'un livre d'or

J'ai modifier un formulaire de livre d'or pour y ajouter un cryptograph.
Mais je suis perdu dans la façon de "mixer" les 2.
Car avec et sans j'ai 2 fonctions.
celui sans donne :
<form action="<?php echo $PHP_SELF; ?>" method="post" name="form">
celui avec donne :
<form action="crypt/verifier.php?<?PHP echo SID; ?>" method="post">

j'ajoute la source de verifier.php au cas ou je puisse ajouter juste ça (j'y arrive pas car j'suis assez nul !)

Code :
1
2
3
4
5
6
7
8
9
10
11
12
<?php 
$cryptinstall="./cryptographp.fct.php";
include $cryptinstall; 
?>
 
<html>
<?php
  if (chk_crypt($_POST['code'])) 
     echo "<a><font color='#009700'>=> Bravo, vous avez saisi le bon code !</font></a>" ;
     else echo "<a><font color='#FF0000'>=> Erreur, le code est incorrect</font></a>" ;
?>
</html>
Si vous voulez les sources des deux pages php contenant le formulaire, dites le !
Spike21 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/04/2007, 18h57   #2
Membre chevronné
 
Avatar de Hervé Saladin
 
Développeur Web
Inscription : décembre 2004
Messages : 636
Détails du profil
Informations personnelles :
Âge : 30

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : décembre 2004
Messages : 636
Points : 689
Points : 689
quel est ton problème ? qu'est-ce qui ne marche pas ? personne ne te répondra jamais si tu restes aussi flou et incompréhensible.
__________________
Ne cliquez pas sur ce lien
Hervé Saladin est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/04/2007, 19h18   #3
Candidat au titre de Membre du Club
 
Inscription : juin 2006
Messages : 92
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 92
Points : 12
Points : 12
Ben quand je met le cryptographe (index.php), le message s'enregistre pas et il me renvoie sur vérifier.php.

Faut que je trouve comment vérifier tout en laissant le "action" du formulaire (index2.php) intacte.

code du index.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?php 
$cryptinstall="crypt/cryptographp.fct.php";
include $cryptinstall; 
?>
 
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript"><!--
function setsmiley(which) {
document.form.comment.value += which+" ";
document.form.comment.focus();
}
//--></script>
 
<?php include ("config.inc.php"); ?>
 
<style type="text/css"><!--
td,body {
	background-image: url(images/fond.jpg);
	font-size:12px;
	font-family:Verdana,Arial,Helvetica,sans-serif}
input,textarea {color: #FFFFFF;
background-color: #000000}
--></style>
</head>
 
<body bgcolor="<?php echo $bgcolor; ?>" text="<?php echo $textcolor; ?>" link="<?php echo $linkcolor; ?>" vlink="<?php echo $vlinkcolor; ?>">
 
<table width="100%" height="100%"><tr>
<td valign="top"><font face="Verdana,Arial,Helvetica" size="2">
 
<?php
 
// if the form has been submitted, do the following
if($submitform) {
 
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$comment = $HTTP_POST_VARS['comment'];
$website = $HTTP_POST_VARS['website'];
 
// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "$dcheck[$check] manquant<br>";
}
}
 
if ((!ereg(".+\@.+\..+", $email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $email))){
$error .= "Adresse email invalide<br>";}
 
// display errors
if($error) {
?>
 
<b>Erreur</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">Essayez de nouveau</a>
<p>
 
<?php
}
else 
{
 
// remove html from the post, and set user variables
if ($allowHTML == no):
$comment = str_replace("<","&lt;",$comment);
$comment = str_replace(">","&gt;",$comment);
endif;
 
$name = str_replace("<","&lt;",$name);
$name = str_replace(">","&gt;",$name);
$name = str_replace("|","l",$name);
$name = stripslashes($name);
 
$email = str_replace("<","&lt;",$email);
$email = str_replace(">","&gt;",$email);
$email = str_replace("|","l",$email);
 
$website = str_replace("<","&lt;",$website);
$website = str_replace(">","&gt;",$website);
$website = str_replace("|","l",$website);
 
$comment = str_replace("\r\n","<br>",$comment);
$comment = str_replace("\r\n","<br>",$comment);
$comment = str_replace("|","l",$comment);
$comment = str_replace("\n","<br>",$comment);
$comment = stripslashes($comment);
 
// change smilies to images
$comment = ereg_replace(":)","<img src=images/smile.gif>",$comment);
$comment = ereg_replace(":o","<img src=images/gasp.gif>",$comment);
$comment = ereg_replace(":D","<img src=images/grin.gif>",$comment);
$comment = ereg_replace(":P","<img src=images/stick.gif>",$comment);
$comment = ereg_replace(";)","<img src=images/wink.gif>",$comment);
$comment = ereg_replace(":&lt;","<img src=images/sadd.gif>",$comment);
 
// replace cuss words with pretty words
$comment = ereg_replace("fuck","love",$comment);
$comment = ereg_replace("shit","love",$comment);
$comment = ereg_replace("cunt","love",$comment);
$comment = ereg_replace("dick","love",$comment);
$comment = ereg_replace("piss","love",$comment);
$comment = ereg_replace("wank","love",$comment);
$comment = ereg_replace("cocksucker","lovely thing",$comment);
$comment = ereg_replace("bitch","lovely thing",$comment);
$comment = ereg_replace("whore","lovely thing",$comment);
 
$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;
$date = date("\l\e d/m/Y \à H\hi", time());
 
// format post
$post = "<table border=0 bgcolor=$bordercolor callpadding=1 cellspacing=0><tr>
<td><table border=0 width=400 bgcolor=$bgcolor><tr>
<td width=80><b>Date:</b></td>
<td width=320>$date</td>
</tr><tr>
<td><b>Nom:</b></td>
<td><a href=mailto:$email>$name</a></td>
</tr><tr>
<td><b>Site:</b></td>
<td><a href=$website target=_blank>$website</a></td>
</tr><tr>
<td colspan=2>$comment</td>
</tr></table></td>
</tr></table>
<p>\n\n";
 
// open guestbook.inc and prepare to write entry
$inc = "guestbook.inc";
$book = fopen("$inc", "r+");
 
// if guestbook.inc won't open
if(!$book) die ("Error reading file.");
 
// write new entry to top of file
flock($book,1);
$old_data = fread($book, filesize($inc));
rewind($book);
fwrite($book, "$post" . $old_data); 
flock($book,3);
fclose($book);
 
// format notification email
$message = "$subject:
 
Nom: $name
Email: $email
Site Web: $website
 
Commentaires: $comment
 
-----------------------------
 
Explorateur: $browser
Ip: $ip";
 
// send notification email
mail($recipientemail,"$subject","$message","From: $name <$email>");
 
// send auto reponse message
if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}
 
// print thank you message
echo "$thanks";
}
}
 
// if the form has not been submitted yet, display the following
else {
?>
 
<a name="top"></a>
<center>
<b>Messages du Guestbook</b><br>
<small><a href="#sign">Signer le Guestbook</a></small>
<p>
 
<?php include('guestbook.inc'); ?>
 
<a name="sign"></a>
 
<form action="crypt/verifier.php?<?PHP echo SID; ?>" method="post">
 
<input type="hidden" name="require" value="name,email,comment">
<table><tr> 
<td colspan="2" align="center"><b>Signer le Guestbook</b><p></td>
</tr><tr> 
<td valign="top" align="right">Name:</td>
<td valign="top"><input type="text" text-color="#000000" name="name" size="20"></td>
</tr><tr> 
<td valign="top" align="right">Email:</td>
<td valign="top"><input type="text" name="email" size="20"></td>
</tr><tr> 
<td valign="top" align="right">Website:</td>
<td valign="top"><input type="text" name="website" value="http://" size="20"></td>
</tr><tr> 
<td valign="top" align="right">Comments</td>
<td valign="top"><textarea name="comment" cols="35" rows="5"></textarea></td>
</tr><tr> 
<td valign="top" align="right">Smileys</td>
<td valign="top">&nbsp;<a href="javascript:setsmiley(':)')"><img src="images/smile.gif" alt=":)" border="0"></a>
<a href="javascript:setsmiley(':<')"><img src="images/sadd.gif" alt=":<" border="0"></a>
<a href="javascript:setsmiley(':D')"><img src="images/grin.gif" alt=":D" border="0"></a>
<a href="javascript:setsmiley(':P')"><img src="images/stick.gif" alt=":P" border="0"></a>
<a href="javascript:setsmiley(';)')"><img src="images/wink.gif" alt=";)" border="0"></a>
<a href="javascript:setsmiley(':o')"><img src="images/gasp.gif" alt=":o" border="0"></a></td>
</tr>
<tr>
<td valign="top" align="right"><?php dsp_crypt(0,1); ?></td>
<td align="top"><input type="text" name="code"></td></tr>
 
<tr>
<td colspan="2" align="center"><input type="submit" value="Envoyer" name="submitform">
<input type="reset" value="Effacer" name="reset"></td>
</tr></table>
<small><a href="#top">Retour en haut</a></small>
<br></center>
 
<?php } ?>
 
</font><p></td>
</tr><tr>
<td valign="bottom"></td>
</tr></table>
 
</body>
</html>
code du index2.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript"><!--
function setsmiley(which) {
document.form.comment.value += which+" ";
document.form.comment.focus();
}
//--></script>
 
<?php include ("config.inc.php"); ?>
 
<style type="text/css"><!--
td,body {
	background-image: url(images/fond.jpg);
	font-size:12px;
	font-family:Verdana,Arial,Helvetica,sans-serif}
input,textarea {color: #FFFFFF;
background-color: #000000}
--></style>
</head>
 
<body bgcolor="<?php echo $bgcolor; ?>" text="<?php echo $textcolor; ?>" link="<?php echo $linkcolor; ?>" vlink="<?php echo $vlinkcolor; ?>">
 
<table width="100%" height="100%"><tr>
<td valign="top"><font face="Verdana,Arial,Helvetica" size="2">
 
<?php
 
// if the form has been submitted, do the following
if($submitform) {
 
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$comment = $HTTP_POST_VARS['comment'];
$website = $HTTP_POST_VARS['website'];
 
// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "$dcheck[$check] manquant<br>";
}
}
 
if ((!ereg(".+\@.+\..+", $email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $email))){
$error .= "Adresse email invalide<br>";}
 
// display errors
if($error) {
?>
 
<b>Erreur</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">Essayez de nouveau</a>
<p>
 
<?php
}
else 
{
 
// remove html from the post, and set user variables
if ($allowHTML == no):
$comment = str_replace("<","&lt;",$comment);
$comment = str_replace(">","&gt;",$comment);
endif;
 
$name = str_replace("<","&lt;",$name);
$name = str_replace(">","&gt;",$name);
$name = str_replace("|","l",$name);
$name = stripslashes($name);
 
$email = str_replace("<","&lt;",$email);
$email = str_replace(">","&gt;",$email);
$email = str_replace("|","l",$email);
 
$website = str_replace("<","&lt;",$website);
$website = str_replace(">","&gt;",$website);
$website = str_replace("|","l",$website);
 
$comment = str_replace("\r\n","<br>",$comment);
$comment = str_replace("\r\n","<br>",$comment);
$comment = str_replace("|","l",$comment);
$comment = str_replace("\n","<br>",$comment);
$comment = stripslashes($comment);
 
// change smilies to images
$comment = ereg_replace(":)","<img src=images/smile.gif>",$comment);
$comment = ereg_replace(":o","<img src=images/gasp.gif>",$comment);
$comment = ereg_replace(":D","<img src=images/grin.gif>",$comment);
$comment = ereg_replace(":P","<img src=images/stick.gif>",$comment);
$comment = ereg_replace(";)","<img src=images/wink.gif>",$comment);
$comment = ereg_replace(":&lt;","<img src=images/sadd.gif>",$comment);
 
// replace cuss words with pretty words
$comment = ereg_replace("fuck","love",$comment);
$comment = ereg_replace("shit","love",$comment);
$comment = ereg_replace("cunt","love",$comment);
$comment = ereg_replace("dick","love",$comment);
$comment = ereg_replace("piss","love",$comment);
$comment = ereg_replace("wank","love",$comment);
$comment = ereg_replace("cocksucker","lovely thing",$comment);
$comment = ereg_replace("bitch","lovely thing",$comment);
$comment = ereg_replace("whore","lovely thing",$comment);
 
$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;
$date = date("\l\e d/m/Y \à H\hi", time());
 
// format post
$post = "<table border=0 bgcolor=$bordercolor callpadding=1 cellspacing=0><tr>
<td><table border=0 width=400 bgcolor=$bgcolor><tr>
<td width=80><b>Date:</b></td>
<td width=320>$date</td>
</tr><tr>
<td><b>Nom:</b></td>
<td><a href=mailto:$email>$name</a></td>
</tr><tr>
<td><b>Site:</b></td>
<td><a href=$website target=_blank>$website</a></td>
</tr><tr>
<td colspan=2>$comment</td>
</tr></table></td>
</tr></table>
<p>\n\n";
 
// open guestbook.inc and prepare to write entry
$inc = "guestbook.inc";
$book = fopen("$inc", "r+");
 
// if guestbook.inc won't open
if(!$book) die ("Error reading file.");
 
// write new entry to top of file
flock($book,1);
$old_data = fread($book, filesize($inc));
rewind($book);
fwrite($book, "$post" . $old_data); 
flock($book,3);
fclose($book);
 
// format notification email
$message = "$subject:
 
Nom: $name
Email: $email
Site Web: $website
 
Commentaires: $comment
 
-----------------------------
 
Explorateur: $browser
Ip: $ip";
 
// send notification email
mail($recipientemail,"$subject","$message","From: $name <$email>");
 
// send auto reponse message
if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}
 
// print thank you message
echo "$thanks";
}
}
 
// if the form has not been submitted yet, display the following
else {
?>
 
<a name="top"></a>
<center>
<b>Messages du Guestbook</b><br>
<small><a href="#sign">Signer le Guestbook</a></small>
<p>
 
<?php include('guestbook.inc'); ?>
 
<a name="sign"></a>
<form action="<?php echo $PHP_SELF; ?>" method="post" name="form">
<input type="hidden" name="require" value="name,email,comment">
<table><tr> 
<td colspan="2" align="center"><b>Signer le Guestbook</b><p></td>
</tr><tr> 
<td valign="top" align="right">Name:</td>
<td valign="top"><input type="text" text-color="#000000" name="name" size="20"></td>
</tr><tr> 
<td valign="top" align="right">Email:</td>
<td valign="top"><input type="text" name="email" size="20"></td>
</tr><tr> 
<td valign="top" align="right">Website:</td>
<td valign="top"><input type="text" name="website" value="http://" size="20"></td>
</tr><tr> 
<td valign="top" align="right">Comments</td>
<td valign="top"><textarea name="comment" cols="35" rows="5"></textarea></td>
</tr><tr> 
<td valign="top" align="right">Smileys</td>
<td valign="top">&nbsp;<a href="javascript:setsmiley(':)')"><img src="images/smile.gif" alt=":)" border="0"></a>
<a href="javascript:setsmiley(':<')"><img src="images/sadd.gif" alt=":<" border="0"></a>
<a href="javascript:setsmiley(':D')"><img src="images/grin.gif" alt=":D" border="0"></a>
<a href="javascript:setsmiley(':P')"><img src="images/stick.gif" alt=":P" border="0"></a>
<a href="javascript:setsmiley(';)')"><img src="images/wink.gif" alt=";)" border="0"></a>
<a href="javascript:setsmiley(':o')"><img src="images/gasp.gif" alt=":o" border="0"></a></td>
</tr>
 
<tr>
<td colspan="2" align="center"><input type="submit" value="Envoyer" name="submitform">
<input type="reset" value="Effacer" name="reset"></td>
</tr></table>
<small><a href="#top">Retour en haut</a></small>
<br></center>
 
<?php } ?>
 
</font><p></td>
</tr><tr>
<td valign="bottom"></td>
</tr></table>
 
</body>
</html>
Spike21 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/04/2007, 09h31   #4
Candidat au titre de Membre du Club
 
Inscription : juin 2006
Messages : 92
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 92
Points : 12
Points : 12
Cherchez plus, j'ai trouvé !
Spike21 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 06h20.


 
 
 
 
Partenaires

Hébergement Web