Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 03:55

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[PHP/OOP]Registratiosn Problem

Discussion on [PHP/OOP]Registratiosn Problem within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1

 
iKyroja :>'s Avatar
 
elite*gold: 20
Join Date: May 2010
Posts: 2,792
Received Thanks: 1,988
[PHP/OOP]Registratiosn Problem

Hayho,

Wen ich das Script ausführe wird die hp weiß, also iwas ist falsch,
was ich aber gemerkt habe das es an "checkInput" liegt, ich
finden dein Fehler aber nicht und habs schon 1000mal geändert.

PHP Code:
<?php
class registration {
    private 
$login;
    private 
$password;
    private 
$email;
    private 
$rl_name;
    private 
$social_id;
    private 
$question1;
    private 
$answer1;
    
    public function 
__construct() {
        
$this->login      mysql_real_escape_string($_POST['login']);
        
$this->password  mysql_real_escape_string($_POST['password']);
        
$this->email     mysql_real_escape_string($_POST['email']);
        
$this->rl_name      mysql_real_escape_string($_POST['rl_name']);
        
$this->social_id mysql_real_escape_string($_POST['social_id']);
        
$this->question1 mysql_real_escape_string($_POST['question1']);
        
$this->answer1   mysql_real_escape_string($_POST['answer1']);
    }
    
    public function 
checkUser() {
        
$checkId mysql_num_rows(mysql_query("SELECT login FROM account.account WHERE login = '$this->login'"));
        if(
$checkId  == 0) {
            return 
true;
        } else {
            return 
false;
        }
        
    }
    
    public function 
ceckInput() {
        if(empty(
$this->login) && strlen($this->login) < 7)  {
            
$error $error.'Der AccountID muss min. 7 Zeichen lang sein';    
        }    
        if(empty(
$this->password) && strlen($this->password) < 7) { 
            
$error $error.'Das Passwort muss min. 7 Zeichen lang sein';    
        }
        if(!
preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i"$this->email))  {
            
$error $error.'Du hast eine inkorrekte Email angegeben';    
        }
        if(empty(
$this->rl_name))  {
            
$error $error.'Du hast deinen Namen nicht angegeben';
        }
        if(empty(
$this->social_id) && strlen($this->social_id) == 8)  {
            
$error $error.'Der Löschcode muss 7 Zeichen lang sein';    
        }
        if(empty($
$this->answer1))  {
            
$error $error.'Du hast die Sicherheitsfrage nicht beantwortet';
        }
        if(!
$this->checkUser())  {
            
$error $error.'Der AccountID existiert bereits';
        }
        
        if(
strlen($error) > 0) {
            return 
true;
        } else {
            return 
false;
        }
                            
    }
    
    
    public function 
insertsql() {
        
$sqlInsert mysql_query("INSERT INTO 
                                  account.account
                                  (login,password,email,real_name,social_id,question1,answer1)
                                  VALUES
                                  ('
$this->login',PASSWORD('$this->password'),'$this->email','$this->rl_name','$this->social_id','$this->question1','$this->answer1')");
        if(
$sqlInsert) {
            return 
true;
        } else {
            return 
false;
        }
    }
    
    public function 
process() {
        if(
$this->ceckInput()) {            
                if(
$this->insertsql()) {
                    echo 
'<div id="succes">SUCCES: Du hast erfolgreich den Account <i>"'.$this->login.'"</i> erstellt</div>';
                } else {
                    echo 
'<div id="error">ERROR: FATAL MYSQL ERROR</div> </ br>'.mysql_error();
                }                                
        } else {
                echo 
$error.'<br />';
        }
    }
}
?>
iKyroja :> is offline  
Old 01/26/2012, 21:36   #2
 
elite*gold: 0
Join Date: Oct 2008
Posts: 319
Received Thanks: 88
Die Varialble $error gilt nur im Geltungsbereich der jeweiligen Methode, d.h wenn du die Variable
nicht zurückgibst kannst du auch nicht in einer anderen Methode auf sie zugreifen, esseiden du
verwendest das global keyword, was du aber nicht tun solltest. Eine Möglichkeit wäre anstelle
einer variable eine eigenschaft zu verwenden (also $this->error).

Nebenbei, das ist keine OOP, den den Grundgedanken der OOP hast du verfehlt. Code und
Ausgabe in einem Script sind in der OOP ein No-Go
Fratyr is offline  
Old 01/27/2012, 12:30   #3

 
iKyroja :>'s Avatar
 
elite*gold: 20
Join Date: May 2010
Posts: 2,792
Received Thanks: 1,988
habe es mit $this->error auch schon probiert, geht nicht
iKyroja :> is offline  
Old 01/27/2012, 18:48   #4
 
elite*gold: 0
Join Date: Oct 2008
Posts: 319
Received Thanks: 88
Du neutralisierst auserdem in deiner Prüfung deine Operatoren.

Quote:
empty($this->login) && strlen($this->login) < 7
Dies trifft also nur zu wenn das login feld Leer ist UND mehr als
7 Zeichen hat. Du musst also den || Operator verwenden und
nicht &&
Fratyr is offline  
Old 01/27/2012, 21:43   #5

 
iKyroja :>'s Avatar
 
elite*gold: 20
Join Date: May 2010
Posts: 2,792
Received Thanks: 1,988
Quote:
Originally Posted by Fratyr View Post
Du neutralisierst auserdem in deiner Prüfung deine Operatoren.


Dies trifft also nur zu wenn das login feld Leer ist UND mehr als
7 Zeichen hat. Du musst also den || Operator verwenden und
nicht &&
Ja es geht schon LAAAAANGE und das "||" ist auch drinne,
ich hab das iwan abens geschreiben ich war da verpeilt
iKyroja :> is offline  
Reply


Similar Threads Similar Threads
Gameguard Problem -.- gebe 20 e*gold wenn das Problem gelöst wurde
09/19/2011 - Wolfteam - 18 Replies
Hab GG Problem 114.wenn ich Emisoft Antimalware anmache habe ich dieses Problem nicht,aber ich habe keine Lizenz mehr.Bei Emisoft Antimalware sind ausserdem alle Ports für WolfTeam offnen,woran kann das denn liegen-.-??
[Problem]Habe ein Problem und zwar spinnt mein VPC etwas(ohne Grund)?!
07/28/2011 - Metin2 Private Server - 10 Replies
Also wie schon gesagt meins Server spinnt wodurch kiks usw. kommen :( ich lade euch die Screens in den Anhang, mit der Hoffnung, dass ihr mir helfen könnt :) wäre echt sehr nice :)



All times are GMT +2. The time now is 03:55.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.