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 disparu une fois le site heberge


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Octobre 2008
    Messages
    104
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 104
    Par défaut captcha disparu une fois le site heberge
    Bonjour,
    Alors j'ai un formulaire d'inscription avec un champs pour le captcha et ça marche bien chez moi , mais une fois heberge l'image du captcha disparait!
    voila comment je fais appel dans mon formulaire :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    <td><img src="view/captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' >
    <input id="6_letters_code" name="6_letters_code" type="text" onblur="verifEmpty(this);"></td>
    le fichier captcha_code_file.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
     
    <?php 
     
    session_start();
    //Settings: You can customize the captcha here
    $image_width = 120;
    $image_height = 40;
    $characters_on_image = 6;
    $font = 'monofont.ttf';
     
    //The characters that can be used in the CAPTCHA code.
    //avoid confusing characters (l 1 and i for example)
    $possible_letters = '23456789bcdfghjkmnpqrstvwxyz';
    $random_dots = 0;
    $random_lines = 20;
    $captcha_text_color="0x142864";
    $captcha_noice_color = "0x142864";
     
    $code = '';
     
     
    $i = 0;
    while ($i < $characters_on_image) { 
    $code .= substr($possible_letters, mt_rand(0, strlen($possible_letters)-1), 1);
    $i++;
    }
     
     
    $font_size = $image_height * 0.75;
    $image = @imagecreate($image_width, $image_height);
     
     
    /* setting the background, text and noise colours here */
    $background_color = imagecolorallocate($image, 255, 255, 255);
     
    $arr_text_color = hexrgb($captcha_text_color);
    $text_color = imagecolorallocate($image, $arr_text_color['red'], 
    		$arr_text_color['green'], $arr_text_color['blue']);
     
    $arr_noice_color = hexrgb($captcha_noice_color);
    $image_noise_color = imagecolorallocate($image, $arr_noice_color['red'], 
    		$arr_noice_color['green'], $arr_noice_color['blue']);
     
     
    /* generating the dots randomly in background */
    for( $i=0; $i<$random_dots; $i++ ) {
    imagefilledellipse($image, mt_rand(0,$image_width),
     mt_rand(0,$image_height), 2, 3, $image_noise_color);
    }
     
     
    /* generating lines randomly in background of image */
    for( $i=0; $i<$random_lines; $i++ ) {
    imageline($image, mt_rand(0,$image_width), mt_rand(0,$image_height),
     mt_rand(0,$image_width), mt_rand(0,$image_height), $image_noise_color);
    }
     
     
    /* create a text box and add 6 letters code in it */
    $textbox = imagettfbbox($font_size, 0, $font, $code); 
    $x = ($image_width - $textbox[4])/2;
    $y = ($image_height - $textbox[5])/2;
    imagettftext($image, $font_size, 0, $x, $y, $text_color, $font , $code);
     
     
    /* Show captcha image in the page html page */
    header('Content-Type: image/jpeg');// defining the image type to be shown in browser widow
    imagejpeg($image);//showing the image
    imagedestroy($image);//destroying the image instance
    $_SESSION['6_letters_code'] = $code;
     
    function hexrgb ($hexstr)
    {
      $int = hexdec($hexstr);
     
      return array("red" => 0xFF & ($int >> 0x10),
                   "green" => 0xFF & ($int >> 0x8),
                   "blue" => 0xFF & $int);
    }
    ?>
    j'ai bien verifie qu'il trouve le fichier captcha_code_file.php avec file_exists.

    Merci pour votre aide

  2. #2
    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
    Si tu appelles directement captcha_code_file.php dans ton navigateur tu obtiens quelque chose ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Par défaut
    Question bête : GD est bien activé sur ton serveur distant ?
    Modératrice PHP
    Aucun navigateur ne propose d'extension boule-de-cristal : postez votre code et vos messages d'erreurs. (Rappel : "ça ne marche pas" n'est pas un message d'erreur)
    Cherchez un peu avant poser votre question : Cours et Tutoriels PHP - FAQ PHP - PDO une soupe et au lit !.

    Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]

  4. #4
    Membre confirmé
    Inscrit en
    Octobre 2008
    Messages
    104
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 104
    Par défaut
    sabotage : ac mon localhost, quand j'appel le fichier directement il m'affiche l'image voulu , mais sur le site hébergé j'obtient toujours le petit icone comme quoi l'image n'existe pas!

    Celira : selon l’hébergeur : oui , voila http://www.000webhost.com/features

  5. #5
    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
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    header('Content-Type: image/jpeg');// defining the image type to be shown in browser widow
    imagejpeg($image);//showing the image
    enleve ces deux lignes et ré-appelle l'image, tu devrais avoir un message d'erreur
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  6. #6
    Membre confirmé
    Inscrit en
    Octobre 2008
    Messages
    104
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 104
    Par défaut
    deux warniing :
    Warning: imagettfbbox() [function.imagettfbbox]: Could not find/open font in /home/a7754846/public_html/alansari/view/captcha_code_file.php on line 74
    c.a.d la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     $textbox = imagettfbbox($font_size, 0, $font, $code);
    et
    Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/a7754846/public_html/alansari/view/captcha_code_file.php on line 77
    ->
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    imagettftext($image, $font_size, 0, $x, $y, $text_color, $font , $code);

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

Discussions similaires

  1. Une fois publier mon site ne fonctionne plus
    Par Gregory.M dans le forum ASP.NET
    Réponses: 0
    Dernier message: 03/02/2009, 11h58
  2. Réponses: 2
    Dernier message: 08/12/2008, 14h19
  3. Donner le focus au body une fois le site chargé
    Par Baldy dans le forum Webdesign & Ergonomie
    Réponses: 4
    Dernier message: 28/11/2008, 14h12
  4. Site entièrement en Flash -> Problèmes une fois en ligne
    Par barbo_Africa dans le forum Intégration
    Réponses: 1
    Dernier message: 23/11/2007, 12h08
  5. Hebergement + GD (encore une fois)
    Par legillou dans le forum Langage
    Réponses: 6
    Dernier message: 28/07/2006, 13h19

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