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 :

Captcha fonctionne mal


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Webdesigner
    Inscrit en
    Avril 2005
    Messages
    120
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Webdesigner

    Informations forums :
    Inscription : Avril 2005
    Messages : 120
    Par défaut Captcha fonctionne mal
    voici un simple code clacul simple de captcha
    fichier : contact.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
     
    <?php session_start(); 
    $signes = array('+','*','/');
    $nombre1 = rand(1,20);
    $nombre2 = rand(10,50);
    $lesigne = $signes[rand(0,2)];
    $calcul = "$nombre1$lesigne$nombre2";
    ?>
    <div id="zone_texte">
    	<div id="titre_rubrique"><h1>Contact</h1></div>
      <h2 style=" margin:5px auto; padding:5px 0px"></h2>
     
     
        <div style="width:470px; float:right; margin-bottom:30px !important; overflow:hidden; border-left:1px dashed #a5a5a5"><FORM action="contact2.php" method="POST" enctype="multipart/form-data" name="contact">
          <table id="contacttab">
              <tr>
                <td align="right"> <label for="f1-nom">Nom:</label></td>
                <td><input name="f1-nom" type="text" id="f1-nom" /></td>
                </tr>
              <tr>
                <td align="right"><label for="f1-prenom">Prénom:</label> </td>
                <td><input name="f1-prenom" type="text" id="f1-prenom" /></td> 
                </tr>
              <tr>
                <td align="right"><label for="f1-adresse">Adresse:
                  <span class="info">(Numéro et rue)</span></label> 
                  :</td>
                <td><input name="f1-adresse" type="text" id="f1-adresse" /> </td>
                </tr>
              <tr>
                <td align="right"><label for="f1-ville">E-mail:
                  <span class="info">(adresse électronique)</span></label> 
                  :</td>
                <td><input name="f1-mail" type="text" id="f1-mail" /> </td>
                </tr>
              <tr>
                <td align="right"><label for="f1-telephone">Téléphone:</label> </td>
                <td><input name="f1-telephone" type="text" id="f1-telephone" /> </td>
                </tr>
     
              <tr>
                <td align="right"><label for="f1-infos">Votre message:</label> </td>
                <td><textarea name="f1-infos" id="f1-infos" rows="5" cols="30" style="height:120px; width:280px"></textarea> </td>
                </tr>
     
    		  <tr>
                <td align="right"><label for="f1-telephone"><?php echo $calcul; ?> = </label> </td>
                <td><input name="reponsecaptcha2" type="text" id="f1-telephone" /> </td>
                </tr>
     
     
              <tr>
                <td></td>
                <td> 
                <input id="searchdomaine" name="envoyer" type="submit" style="float:right; display:block; margin-right:70px; width:120px; border-color:#1ab2e8; padding:5px !important; height:30px !important;"   onClick="mail1()" value="Envoyer" title="Envoyer le formulaire" >
                 </td>
                </tr>
              </table>
          </form>
    fichier : contact2.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
     
    <?php
     
    session_start();
    	if(isset($_POST['envoyer'])){
    	if(isset($_POST['captchaResult']))
    	{
    		$_POST['captchaResult'] = strtolower($_POST['captchaResult']);
    		$_SESSION['captchaResult'] = strtolower($_SESSION['captchaResult']);
    	}
     
    	if($_POST['captchaResult'] == $_SESSION['captchaResult']){
     
    $to = "rydweb@gmail.com"; 
    $subject = "reponse du blog";
     
    $headers = "From: " . $_POST["f1-nom"]." ". $_POST["f1-prenom"]; 
    $headers .= "<" . $_POST["f1-mail"] . ">\r\n"; 
    $headers .= "Reply-To: " . $_POST["f1-mail"] . "\r\n"; 
    $headers .= "Return-Path: " . $_POST["f1-mail"]; 
     
    $message .= "Nom: " . $_POST["f1-nom"] . "\r\n";
    $message .= "Prenom: " . $_POST["f1-prenom"] . "\r\n";
    $message .= "Adresse: " . $_POST["f1-adresse"] . "\r\n";
    $message .= "E-mail: " . $_POST["f1-mail"] . "\r\n";
    $message .= "Societe: " . $_POST["f1-organisation"] . "\r\n";
    $message .= "Telephone: " . $_POST["f1-telephone"] . "\r\n";
    $message .= "Message: \r\n---------\r\n" . $_POST["f1-infos"] . "\r\n";
     
    $ok=mail($to, $subject, $message, $headers); 
    if ($ok) {
     
     
     
     
     
    }
    ?>
    <span>On vas  Traiter Votre demande . Merci</span>
    le probleme qu'il n'affiche pas la page contact2.php
    en meme si le captcha et faux , le message s'envoie ....

    Merci

  2. #2
    Membre expérimenté Avatar de stephanegib2
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2011
    Messages
    152
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2011
    Messages : 152
    Par défaut
    Cela veut dire que $_POST['captchaResult'] == $_SESSION['captchaResult'].

    Vérifie les valeurs et ta façon de mettre à jour $_SESSION['captchaResult'].

  3. #3
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Je dirais même que $_POST['captchaResult'] == $_SESSION['captchaResult'] == NULL.

    Il n'y a pas "captchaResult" dans ton formulaire, il y a "reponsecaptcha2".
    Et nul part tu ne renseignes la session.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  4. #4
    Membre confirmé
    Homme Profil pro
    Webdesigner
    Inscrit en
    Avril 2005
    Messages
    120
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Webdesigner

    Informations forums :
    Inscription : Avril 2005
    Messages : 120
    Par défaut
    bonjour ,
    j'ai changer le ID
    toujours la meme chose .

  5. #5
    Membre expérimenté Avatar de stephanegib2
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2011
    Messages
    152
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2011
    Messages : 152
    Par défaut
    Comme dit plus haut. $_SESSION['resultatcaptcha2'] n'existe pas. Il est défini nul part.

Discussions similaires

  1. Réponses: 5
    Dernier message: 29/05/2008, 12h42
  2. gtk_list_store_append fonctionne mal
    Par TONIAPEL dans le forum GTK+ avec C & C++
    Réponses: 3
    Dernier message: 04/09/2007, 01h10
  3. Démo qui fonctionne mal sur Mac OS
    Par shams dans le forum Ogre
    Réponses: 12
    Dernier message: 22/05/2007, 19h34
  4. [FTP] Upload par ftp fonctionne mal
    Par lr dans le forum Langage
    Réponses: 3
    Dernier message: 26/01/2007, 19h19
  5. un DELETE qui fonctionne mal
    Par HULK dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 06/02/2006, 19h59

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