error!!!


  1. #1
    Fan Stiinta bibistroc's Avatar bibistroc va deveni faimos in curand
    Data de inscriere
    19-10-2006
    Locaţie
    Craiova, Romania
    Varsta
    33
    Sex
    M
    Mesaje
    193
    Mesaje bazar
    268
    Putere Reputatie
    36
    Reputatie
    56
    Puncte CF
    20.0
    Usergroups:

    error!!!

    Am facut rost de un script care afiseaza un cod de securitate:
    PHP Cod:
    <?php
    session_start
    ();

    /*
    * File: security.php
    * Author: Simon Jarvis
    * Copyright: 2006 Simon Jarvis
    * Date: 03/08/06
    * Updated: 07/02/07
    * Requirements: PHP 4/5 with GD and FreeType libraries
    * Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php

    * This program is free software; you can redistribute it and/or 
    * modify it under the terms of the GNU General Public License 
    * as published by the Free Software Foundation; either version 2 
    * of the License, or (at your option) any later version.

    * This program is distributed in the hope that it will be useful, 
    * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    * GNU General Public License for more details: 
    * http://www.gnu.org/licenses/gpl.html
    *
    */

    class CaptchaSecurityImages {

        var 
    $font 'monofont.ttf';

        function 
    generateCode($characters) {
            
    /* list all possible characters, similar looking characters and vowels have been removed */
            
    $possible '23456789bcdfghjkmnpqrstvwxyz';
            
    $code '';
            
    $i 0;
            while (
    $i $characters) { 
                
    $code .= substr($possiblemt_rand(0strlen($possible)-1), 1);
                
    $i++;
            }
            return 
    $code;
        }

        function 
    CaptchaSecurityImages($width='120',$height='40',$characters='6') {
            
    $code $this->generateCode($characters);
            
    /* font size will be 75% of the image height */
            
    $font_size $height 0.75;
            
    $image = @imagecreate($width$height) or die('Cannot initialize new GD image stream');
            
    /* set the colours */
            
    $background_color imagecolorallocate($image255255255);
            
    $text_color imagecolorallocate($image2040100);
            
    $noise_color imagecolorallocate($image100120180);
            
    /* generate random dots in background */
            
    for( $i=0$i<($width*$height)/3$i++ ) {
                
    imagefilledellipse($imagemt_rand(0,$width), mt_rand(0,$height), 11$noise_color);
            }
            
    /* generate random lines in background */
            
    for( $i=0$i<($width*$height)/150$i++ ) {
                
    imageline($imagemt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
            }
            
    /* create textbox and add text */
            
    $textbox imagettfbbox($font_size0$this->font$code) or die('Error in imagettfbbox function');
            
    $x = ($width $textbox[4])/2;
            
    $y = ($height $textbox[5])/2;
            
    imagettftext($image$font_size0$x$y$text_color$this->font $code) or die('Error in imagettftext function');
            
    /* output captcha image to browser */
            
    header('Content-Type: image/jpeg');
            
    imagejpeg($image);
            
    imagedestroy($image);
            
    $_SESSION['security_code'] = $code;
        }

    }

    $width = isset($_GET['width']) ? $_GET['width'] : '120';
    $height = isset($_GET['height']) ? $_GET['height'] : '40';
    $characters = isset($_GET['characters']) && $_GET['characters'] > $_GET['characters'] : '6';

    $captcha = new CaptchaSecurityImages($width,$height,$characters);
    ?>
    Eu i-am dar numele de security.php.
    Dar nu stiu de ce da eroare in scriptul asta:
    PHP Cod:
    <?
    if (isset($_COOKIE["user"])) {
    } else {
    include (
    'config.php');
    extract($_POST);
    if (!
    $name) {
    echo 
    "<div align=\"center\"><form method=\"post\" action=\"register.php\">\n";
    echo 
    "User<input type=\"text\" name=\"name\" size=\"25\" maxlength=\"15\" title=\"Name\" class=\"SB_input\"><br>\n";
    echo 
    "Email<input type=\"text\" name=\"mail\" size=\"35\" maxlength=\"35\" title=\"Name\" class=\"SB_input\"><br>\n";
    echo 
    "Parola<input type=\"password\" name=\"pass\" size=\"25\" maxlength=\"15\" title=\"Message\" class=\"SB_input\"><br>\n";
    echo 
    "<img src=\"security.php?width=100&height=40&characters=5\"><br>\n";
    echo 
    "<input type=\"hidden\" name=\"img\" value=\"any.jpg\" size=\"25\" maxlength=\"15\" title=\"Message\" class=\"SB_input\">\n";
    echo 
    "Cod securitate:<input type=\"text\" name=\"cod\" size=\"10\" maxlength=\"5\" title=\"Name\" class=\"SB_input\"><br>\n";
    echo 
    "<input type=\"submit\" name=\"submit\" value=\":: send ::\" class=\"SB_button\">\n";
    echo 
    "<input type=\"button\" name=\"refresh_it\" value=\":: refresh ::\" class='SB_button' onclick=\"window.open('register.php','_self');\">\n";
    $e $_SESSION['security_code'];
    }
    elseif (!
    $_SESSION['security_code']) { echo "Eroare."; }
    elseif (!
    $cod) {
    echo 
    "1Cod de securitate greist!";
    }
    elseif (
    $e !== $cod) {
    echo 
    "2Code de securitate gresit!";
    }
    elseif (!
    $pass) {
    echo 
    "Nu ai introdus o parola!"
    }
    elseif (!
    $mail) {
    echo 
    "Nu ai introdus un mail!";
    } else {
    mysql_connect(localhost,$user,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM users WHERE user='$name'";
    $result=mysql_query($query);
    $ba=mysql_result($result,0,"user");

    if (
    $ba) {
    echo 
    "Userul $name deja exista.";
    } else {  

    mysql_connect(localhost,$user,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query "INSERT INTO users VALUES ('','$name','$pass','$mail','$img')";
    mysql_query($query);
    mysql_close();
    }
    }
    }
    ?>
    Spuneti-mi ce este gresit.
    Nothing Here !

    "Se spune ca unul din 4 oameni este nebun. Gandestete la cei mai apropiati 3 prieteni ai tai.
    Daca ei sunt sanatosi, tu nu esti."

  2. #2
    Coder crick67's Avatar crick67 reprezinta o cantitate neglijabila
    Data de inscriere
    05-01-2007
    Locaţie
    Craiova
    Varsta
    39
    Sex
    M
    Mesaje
    76
    Mesaje bazar
    230
    Putere Reputatie
    36
    Reputatie
    10
    Puncte CF
    25.0
    Usergroups:
    Ce eroare da?
    Vrei mai putine reclame? Inregistreaza-te sau logheaza-te

  3. #3
    Fan Stiinta bibistroc's Avatar bibistroc va deveni faimos in curand
    Data de inscriere
    19-10-2006
    Locaţie
    Craiova, Romania
    Varsta
    33
    Sex
    M
    Mesaje
    193
    Mesaje bazar
    268
    Putere Reputatie
    36
    Reputatie
    56
    Puncte CF
    20.0
    Usergroups:
    nu da o eroare. dar ajunge la linia asta:
    PHP Cod:
    elseif (!$_SESSION['security_code']) { echo "Eroare."; } 
    cea ce inseamana ca scriptul nu primeste $_SESSION['security_code'] .
    error!!! Fisiere atasate 1.JPG   2.JPG  
    Nothing Here !

    "Se spune ca unul din 4 oameni este nebun. Gandestete la cei mai apropiati 3 prieteni ai tai.
    Daca ei sunt sanatosi, tu nu esti."

  4. #4
    Fan Stiinta bibistroc's Avatar bibistroc va deveni faimos in curand
    Data de inscriere
    19-10-2006
    Locaţie
    Craiova, Romania
    Varsta
    33
    Sex
    M
    Mesaje
    193
    Mesaje bazar
    268
    Putere Reputatie
    36
    Reputatie
    56
    Puncte CF
    20.0
    Usergroups:

    Hmm

    ma ajuta cineva?
    daca nu reuseste cu scriptul asta macar sa faca unul asemanator care sa mearga.
    Nothing Here !

    "Se spune ca unul din 4 oameni este nebun. Gandestete la cei mai apropiati 3 prieteni ai tai.
    Daca ei sunt sanatosi, tu nu esti."

  5. #5
    Senior Member Chip's Avatar Chip reprezinta o cantitate neglijabila
    Data de inscriere
    04-10-2005
    Locaţie
    Oltenia, eterna TerraNova
    Varsta
    39
    Sex
    M
    Mesaje
    610
    Mesaje bazar
    155
    Putere Reputatie
    41
    Reputatie
    16
    Puncte CF
    30.5
    Usergroups:
    sesiunea trebuie initializata in fiecare script.

    adauga un session_start() in toate paginile unde folosesti informatii din sesiune (adauga-l la inceput, inainte de a face vreun output) - alta greseala nu vad acum, banuiesc ca folosesti corect clasa pt captcha.
    ...sa fim dintre romani cei mai fierbinti!

  6. #6
    Fan Stiinta bibistroc's Avatar bibistroc va deveni faimos in curand
    Data de inscriere
    19-10-2006
    Locaţie
    Craiova, Romania
    Varsta
    33
    Sex
    M
    Mesaje
    193
    Mesaje bazar
    268
    Putere Reputatie
    36
    Reputatie
    56
    Puncte CF
    20.0
    Usergroups:
    Am pus:
    PHP Cod:
    <?
    session_start
    ();
    if (isset(
    $_COOKIE["user"])) {
    include (
    'r.html');
    } else {
    include (
    'config.php');
    extract($_POST);
    if (!
    $name) {
    echo 
    "<div align=\"center\"><form method=\"post\" action=\"register.php\">\n";
    echo 
    "User<input type=\"text\" name=\"name\" size=\"25\" maxlength=\"15\" title=\"Name\" class=\"SB_input\"><br>\n";
    echo 
    "Email<input type=\"text\" name=\"mail\" size=\"35\" maxlength=\"35\" title=\"Name\" class=\"SB_input\"><br>\n";
    echo 
    "Parola<input type=\"password\" name=\"pass\" size=\"25\" maxlength=\"15\" title=\"Message\" class=\"SB_input\"><br>\n";
    echo 
    "<img src=\"security.php?width=100&height=40&characters=5\"><br>\n";
    echo 
    "<input type=\"hidden\" name=\"img\" value=\"any.jpg\" size=\"25\" maxlength=\"15\" title=\"Message\" class=\"SB_input\">\n";
    echo 
    "Cod securitate:<input type=\"text\" name=\"cod\" size=\"10\" maxlength=\"5\" title=\"Name\" class=\"SB_input\"><br>\n";
    echo 
    "<input type=\"submit\" name=\"submit\" value=\":: send ::\" class=\"SB_button\">\n";
    echo 
    "<input type=\"button\" name=\"refresh_it\" value=\":: refresh ::\" class='SB_button' onclick=\"window.open('register.php','_self');\">\n";
    $e $_SESSION['security_code'];
    }
    elseif (!
    $_SESSION['security_code']) { echo "Eroare."; }
    elseif (!
    $cod) {
    echo 
    "1Cod de securitate greist!";
    }
    elseif (
    $e !== $cod) {
    echo 
    "2Code de securitate gresit!";
    }
    elseif (!
    $pass) {
    echo 
    "Nu ai introdus o parola!"
    }
    elseif (!
    $mail) {
    echo 
    "Nu ai introdus un mail!";
    } else {
    mysql_connect(localhost,$user,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM users WHERE user='$name'";
    $result=mysql_query($query);
    $ba=mysql_result($result,0,"user");

    if (
    $ba) {
    echo 
    "Userul $name deja exista.";
    } else {  

    mysql_connect(localhost,$user,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query "INSERT INTO users VALUES ('','$name','$pass','$mail','$img')";
    mysql_query($query);
    mysql_close();
    }
    }
    }
    ?>
    dar acum imi ajunge la eroarea: 2Code de securitate gresit! in linia :
    Cod:
    elseif ($e !== $cod) {
    echo "2Code de securitate gresit!";
    }
    dar ar trebuii sa fie egal.
    te rog ajutor.
    Nothing Here !

    "Se spune ca unul din 4 oameni este nebun. Gandestete la cei mai apropiati 3 prieteni ai tai.
    Daca ei sunt sanatosi, tu nu esti."

  7. #7
    Senior Member Chip's Avatar Chip reprezinta o cantitate neglijabila
    Data de inscriere
    04-10-2005
    Locaţie
    Oltenia, eterna TerraNova
    Varsta
    39
    Sex
    M
    Mesaje
    610
    Mesaje bazar
    155
    Putere Reputatie
    41
    Reputatie
    16
    Puncte CF
    30.5
    Usergroups:
    pai greseala e de la faptul ca tu citesti pe $e din sesiune numai cand afisezi forumul - daca ai scris la User ceva nu mai intrii pe bucla primului IF, si $e nu mai este citit din sesiune, asa ca e normal ca $e sa fie diferit de $cod (pt ca e null)
    muta linia $e = $_SESSION['security_code']; imediat dupa extract($_POST);

    ar trebui sa mearga
    ...sa fim dintre romani cei mai fierbinti!

  8. #8
    Fan Stiinta bibistroc's Avatar bibistroc va deveni faimos in curand
    Data de inscriere
    19-10-2006
    Locaţie
    Craiova, Romania
    Varsta
    33
    Sex
    M
    Mesaje
    193
    Mesaje bazar
    268
    Putere Reputatie
    36
    Reputatie
    56
    Puncte CF
    20.0
    Usergroups:
    Greseala mea.
    Mersi mult Chip. Acum merge.
    Nothing Here !

    "Se spune ca unul din 4 oameni este nebun. Gandestete la cei mai apropiati 3 prieteni ai tai.
    Daca ei sunt sanatosi, tu nu esti."
    Vrei mai putine reclame? Inregistreaza-te sau logheaza-te

Google+

Cautati logo-ul CraiovaForum?

Iata cateva variante: