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 :

Formulaire d'un livre d'or


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 94
    Points : 37
    Points
    37
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 !

  2. #2
    Membre éclairé Avatar de Hervé Saladin
    Homme Profil pro
    Ingénieur d'études en développement et déploiement d'applications
    Inscrit en
    Décembre 2004
    Messages
    647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur d'études en développement et déploiement d'applications
    Secteur : Service public

    Informations forums :
    Inscription : Décembre 2004
    Messages : 647
    Points : 799
    Points
    799
    Par défaut
    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.

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 94
    Points : 37
    Points
    37
    Par défaut
    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 : 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
    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 : 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
    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>

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 94
    Points : 37
    Points
    37
    Par défaut
    Cherchez plus, j'ai trouvé !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Formulaire critique de livre
    Par nicosmash dans le forum Mode d'emploi & aide aux nouveaux
    Réponses: 3
    Dernier message: 07/09/2013, 12h10
  2. Formulaire livre d'or
    Par Baldric de Dol dans le forum Langage
    Réponses: 2
    Dernier message: 20/06/2008, 14h20
  3. [langage] Je cherche un bon livre ?
    Par Anonymous dans le forum Langage
    Réponses: 13
    Dernier message: 09/04/2003, 13h16
  4. [web] Cherche un conseil pour un livre perl-tk
    Par Anonymous dans le forum Interfaces Graphiques
    Réponses: 2
    Dernier message: 29/04/2002, 15h35

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