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 :

Class et formulaire [PHP 5.3]


Sujet :

Langage PHP

  1. #1
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Class et formulaire
    Bonjour,

    Ce pb est du type syntaxe et/ou architecture de classe en PHP 5 !
    J'ai un formulaire que je souhaite valider.
    Je me crée un script de validation que je pourrais réuitiliser autre part !
    J'ai toute une série de classe mais celles qui nous importe pour l'instant sont:

    CheckForm - pas besoin d'explication
    Text et Interger - des champs du formulaire
    Stack, qui me posait des problèmes.
    Je l'ai donc intégrée à CheckForm !
    Cette classe était pourtant instancée par Chekform et est susceptible de recevoir mes msgs d'erreur générées par les classes Filles (Text & Integer)

    Entre chaque champ, il apparait que le stack est raz (remis à zéro)
    Donc, dans mon formuaire, j'affiche juste un texte et [0]

    voici ma classe CheckForm:

    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
       	class Checkform
    		{	protected $stackMsg = array();
    			protected $cntStack = 0 ;
    			private $msg, $form, $cntField, $cntFilled, $valid ;
     
    			function __construct($form)
    			{	
    user_error("Start of Constructor[".$this->getCntStack()."]" , E_USER_NOTICE) ;
     
    				$this->initForm($form) ;
     
    //
    //              Error Handler
    //				=============				
    				try {
    					$this->Validate() ;
    				}	catch (Exception $E)
    					{	$this->exception_handler($E) ; }
    #
    #				Choix du message en fonction du nbre de champ remplit OUI || NON (qui sera délivré par getMessage)
    #				==================================================================================================	
    				$this->msg = new Message($this->getCntFilled(),$this->getCntField(),$this->isFormValid()) ;
    user_error("End of Constructor[".$this->getCntStack()."]" , E_USER_NOTICE) ;	 
    			}
     
    //          ==================================	
    //          All Stack routines			
    //          ==================================	
    //          ==================================	
    //          All Error Stacking functions			
    //          ==================================	
    			function getCntStack()
    			{	return($this->cntStack) ; }	
     
    			public function getStackError() 				// Public car function appelée fu formulaire...
    			{	
    user_error("getStackError[".$this->cntStack."]" , E_USER_NOTICE) ;	 
    				$str = "" ; 
    print("getStackError ==>[".$this->cntStack."]") ;
    //				print_r($this->stackMsg); 
    				for ($i = 0 ; $i < $this->cntStack ; $i++)
    					$str .= $this->stackMsg[$i] ;
    				return($str) ; 
    			}
     
    			public function stackMessage($msg)
    			{	$this->stackMsg[] = $msg . "<br>\n" ; 
    				$this->cntStack++ ; 
    user_error("+++++++ Stacking msg[".$this->cntStack."][".$msg."]" , E_USER_NOTICE) ;	 
    print("Stacking[".$msg."] - cntStack[".$this->cntStack."]") ;
    //				print_r($this->stackMsg); 
    			}
     
    			public function emptyStack()
    			{	$this->cntStack = 0 ;
    user_error("emptyStack[".$this->cntStack."]" , E_USER_NOTICE) ;	 
    				$this->stackMsg = array() ;	 
    			}
     
    			public function printStack()
    			{	
    user_error("printStack[".$this->cntStack."]" , E_USER_NOTICE) ;
    				for ($i = 0 ; $i < $this->cntStack ; $i++)
    					user_error ("stack[".$this->cntStack."] - " . $this->stackMsg[$i] , E_USER_NOTICE) ;
    			}
     
    //          ==================================	
    //          All Screen message area routines			
    //          ==================================	
    			public function getMessage()                   // Public car function appelée fu formulaire...
    			{	return($this->msg->getMessage()) ;  	}
     
    			public function isFormValid()
    			{	return($this->formValid) ; }
    //          ==================================	
     
    			private function getCntField()
    			{ 	return($this->cntField) ;	}
     
    			private function getCntFilled()
    			{ 	return($this->cntFilled) ;	}
     
    			private function initForm($form)
    			{   $this->form  	  = $form ;
    				$this->cntField   = count($this->form);
    				$this->formValid  = false ;
    				$this->emptyStack() ;
    			}
     
    			function Validate()
    			{	$this->cntFilled = 0 ;
    user_error("Start of Validation ==> cntStack[".$this->getCntStack()."]" , E_USER_NOTICE) ;	 
    				for($i = 0 ; $i < $this->getCntField() ; $i++) 
    				{	if ($this->form[$i] instanceof Validator)
    //						if ($this->form[$i]->Filled() )
    							{	
    user_error("Start Validating field[".$i."]  cntStack[".$this->getCntStack()."]" , E_USER_NOTICE) ;
    								$this->cntFilled++ ;
    								$this->form[$i]->Validate() ; 				
    								$this->printStack() ;
    user_error("End   Validating field[".$i."]  cntStack[".$this->getCntStack()."]" , E_USER_NOTICE) ;
    							}
    				}
    //user_error("End of Validate ==> cntStack[".Stack::getCntStack()."]" , E_USER_NOTICE) ;	 
    			}
    //
    //          Error Handler Processing
    //			========================	
    			private function exception_handler($E)
    			{	$T = $E->getTrace() ; 
    			//	======================================================================
    				print("FORM Validator error diagnostic" .  "<br>\n") ;
    				print("=======================" .  "<br>\n") ;
     				print("Message: " . $E->getMessage() . " - File: " . $E->getFile() . " - Line: " . $E->getLine() . "<br>\n") ;
    				print("<br>\n") ;
    				print("Trace: " . "<br>\n") ;
    				print("------ " . "<br>\n") ;
    				print( "   => File               : " . $T[0]["file"]     . "<br>\n") ;
    				print( "   => calling instruction: " . $T[0]["line"]     . "<br>\n") ;
     				print( "   => error class        : " . $T[0]["class"]    . "<br>\n") ;
    				print( "   => error function     : " . $T[0]["function"] . "<br>\n") ;
    				//	======================================================================
    				user_error("Connexion error in File: (" . $E->getFile() . ") - line: (" . $E->getLine() . ")" , E_USER_WARNING) ;  
       			}
    //	
    //      End of class CheckForm
    //		======================		
    		}
    Voici le log 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
    [28-May-2010 13:17:05] PHP Notice:  Start of Constructor[0] in F:\WebSites\test\checkform.php on line 644
    [28-May-2010 13:17:05] PHP Notice:  emptyStack[0] in F:\WebSites\test\checkform.php on line 692
    
    [28-May-2010 13:17:05] PHP Notice:  Start of Validation ==> cntStack[0] in F:\WebSites\test\checkform.php on line 728
    [28-May-2010 13:17:05] PHP Notice:  Start Validating field[0]  cntStack[0] in F:\WebSites\test\checkform.php on line 733
    
    [28-May-2010 13:17:05] PHP Notice:  +++++++ Stacking msg[1][Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] in F:\WebSites\test\checkform.php on line 685
    [28-May-2010 13:17:05] PHP Notice:  printStack[0] in F:\WebSites\test\checkform.php on line 698
    [28-May-2010 13:17:05] PHP Notice:  End   Validating field[0]  cntStack[0] in F:\WebSites\test\checkform.php on line 737
    
    [28-May-2010 13:17:05] PHP Notice:  Start Validating field[1]  cntStack[0] in F:\WebSites\test\checkform.php on line 733
    [28-May-2010 13:17:05] PHP Notice:  +++++++ Stacking msg[1][Le champ[nom] doit avoir une longueur comprise entre 3 et 30] in F:\WebSites\test\checkform.php on line 685
    [28-May-2010 13:17:05] PHP Notice:  printStack[0] in F:\WebSites\test\checkform.php on line 698
    [28-May-2010 13:17:05] PHP Notice:  End   Validating field[1]  cntStack[0] in F:\WebSites\test\checkform.php on line 737
    
    [28-May-2010 13:17:05] PHP Notice:  Start Validating field[2]  cntStack[0] in F:\WebSites\test\checkform.php on line 733
    [28-May-2010 13:17:05] PHP Notice:  +++++++ Stacking msg[1][Valeur non numérique[4] [9999]] in F:\WebSites\test\checkform.php on line 685
    [28-May-2010 13:17:05] PHP Notice:  printStack[0] in F:\WebSites\test\checkform.php on line 698
    [28-May-2010 13:17:05] PHP Notice:  End   Validating field[2]  cntStack[0] in F:\WebSites\test\checkform.php on line 737
    
    [28-May-2010 13:17:05] PHP Notice:  End of Constructor[0] in F:\WebSites\test\checkform.php on line 659
    [28-May-2010 13:17:05] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 811
    [28-May-2010 13:17:05] PHP Notice:  getStackError[0] in F:\WebSites\test\checkform.php on line 673
    En gras, j'ai mis le cntStack qui est le nombre de message inséré dans le Stack... lequel est bien incrémenté en partant de zéro à chaque champs !!!!)
    Mais c'est justement le problème, il est raz à chaque champs et non au moment du __construct de Checkfom...

    Un p'tit coup de main svp....

  2. #2
    Membre Expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Par défaut
    Bonjour,

    Suffit de rendre statique ta variable $cntStack, sinon elle est évidemment propre à chaque instance.

  3. #3
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Formulaire & class
    Desolé Thomas,

    J'ai déjà essayé....
    Je viens de refaire la modif pour te montrer et tu auras droit à une erreur dans le log php queje ne comprends pas

    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
    [28-May-2010 14:59:59] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 795
    [28-May-2010 14:59:59] PHP Notice:  getStackError[0] in F:\WebSites\test\checkform.php on line 657
    [28-May-2010 15:00:46] PHP Notice:  Undefined property: Checkform::$cntStack in F:\WebSites\test\checkform.php on line 653
    [28-May-2010 15:00:46] PHP Notice:  Start of Constructor[] in F:\WebSites\test\checkform.php on line 628
    [28-May-2010 15:00:46] PHP Notice:  emptyStack[0] in F:\WebSites\test\checkform.php on line 676
    [28-May-2010 15:00:46] PHP Notice:  Start of Validation ==> cntStack[0] in F:\WebSites\test\checkform.php on line 712
    [28-May-2010 15:00:46] PHP Notice:  Start Validating field[0]  cntStack[0] in F:\WebSites\test\checkform.php on line 717
    [28-May-2010 15:00:46] PHP Notice:  +++++++ Stacking msg[1][Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] in F:\WebSites\test\checkform.php on line 669
    [28-May-2010 15:00:46] PHP Notice:  printStack[0] in F:\WebSites\test\checkform.php on line 682
    [28-May-2010 15:00:46] PHP Notice:  End   Validating field[0]  cntStack[0] in F:\WebSites\test\checkform.php on line 721
    [28-May-2010 15:00:46] PHP Notice:  Start Validating field[1]  cntStack[0] in F:\WebSites\test\checkform.php on line 717
    [28-May-2010 15:00:46] PHP Notice:  +++++++ Stacking msg[1][Le champ[nom] doit avoir une longueur comprise entre 3 et 30] in F:\WebSites\test\checkform.php on line 669
    [28-May-2010 15:00:46] PHP Notice:  printStack[0] in F:\WebSites\test\checkform.php on line 682
    [28-May-2010 15:00:46] PHP Notice:  End   Validating field[1]  cntStack[0] in F:\WebSites\test\checkform.php on line 721
    [28-May-2010 15:00:46] PHP Notice:  Start Validating field[2]  cntStack[0] in F:\WebSites\test\checkform.php on line 717
    [28-May-2010 15:00:46] PHP Notice:  +++++++ Stacking msg[1][Le champ[numero] doit avoir une longueur comprise entre 3 et 5] in F:\WebSites\test\checkform.php on line 669
    [28-May-2010 15:00:46] PHP Notice:  printStack[0] in F:\WebSites\test\checkform.php on line 682
    [28-May-2010 15:00:46] PHP Notice:  End   Validating field[2]  cntStack[0] in F:\WebSites\test\checkform.php on line 721
    [28-May-2010 15:00:46] PHP Notice:  End of Constructor[0] in F:\WebSites\test\checkform.php on line 643
    [28-May-2010 15:00:46] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 795
    [28-May-2010 15:00:46] PHP Notice:  getStackError[0] in F:\WebSites\test\checkform.php on line 657
    Voci la classe ou un extrait....

    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
        	class Checkform
    		{	protected $stackMsg = array();
    653 =>		static $cntStack = 0 ;
    			private $msg, $form, $cntField, $cntFilled, $valid ;
    	
    			function __construct($form)
    			{	
    user_error("Start of Constructor[".$this->getCntStack()."]" , E_USER_NOTICE) ;
    				
    				$this->initForm($form) ;
    				
    //
    //              Error Handler
    //				=============				
    				try {
    					$this->Validate() ;
    				}	catch (Exception $E)
    					{	$this->exception_handler($E) ; }
    #
    #				Choix du message en fonction du nbre de champ remplit OUI || NON (qui sera délivré par getMessage)
    #				==================================================================================================	
    				$this->msg = new Message($this->getCntFilled(),$this->getCntField(),$this->isFormValid()) ;
    user_error("End of Constructor[".$this->getCntStack()."]" , E_USER_NOTICE) ;	 
    			}
    			
    //          ==================================	
    //          All Stack routines			
    //          ==================================	
    //          ==================================	
    //          All Error Stacking functions			
    //          ==================================	
    			function getCntStack()
    ICI====>	{	return($this->cntStack) ; }	
    
    			public function getStackError() 				// Public car function appelée fu formulaire...
    			{	
    user_error("getStackError[".$this->cntStack."]" , E_USER_NOTICE) ;	 
    				$str = "" ; 
    print("getStackError ==>[".$this->cntStack."]") ;
    //				print_r($this->stackMsg); 
    				for ($i = 0 ; $i < $this->cntStack ; $i++)
    					$str .= $this->stackMsg[$i] ;
    				return($str) ; 
    			}
    				
    			public function stackMessage($msg)
    			{	$this->stackMsg[] = $msg . "<br>\n" ; 
    				$this->cntStack++ ; 
    user_error("+++++++ Stacking msg[".$this->cntStack."][".$msg."]" , E_USER_NOTICE) ;	 
    print("Stacking[".$msg."] - cntStack[".$this->cntStack."]") ;
    //				print_r($this->stackMsg); 
    			}
    				
    			public function emptyStack()
    			{	$this->cntStack = 0 ;
    user_error("emptyStack[".$this->cntStack."]" , E_USER_NOTICE) ;	 
    				$this->stackMsg = array() ;	 
    			}
    			
    			public function printStack()
    			{	
    user_error("printStack[".$this->cntStack."]" , E_USER_NOTICE) ;
    				for ($i = 0 ; $i < $this->cntStack ; $i++)
    					user_error ("stack[".$this->cntStack."] - " . $this->stackMsg[$i] , E_USER_NOTICE) ;
    			}

    Nous sommes 3 à chercher depuis 2 jours et pas encore trouv"

    Seras-tu le gagnant ?


    SORRY je me suis trompé, ce n'est pas à la déclaration que le message est sortit mais bien au return($this->cntStack), dont à l'utlisation de ce dernier....

  4. #4
    Membre Expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Par défaut
    3 personnes pour si peu ?

    Pour appeler un membre statique il ne faut pas faire référence à l'instance mais à la definition de la classe.

    Je ne peux que te conseiller de lire : http://fr.php.net/manual/fr/language.oop5.static.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    CheckForm::$cntStack++;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    function getCntStack(){
        return self::$cntStack;
    }
    edit : aussi, passes ta variable en public et non protected pour pouvoir la valoriser depuis l'exterieur de ta classe et des classes héritées.

  5. #5
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Privatr ptoperty
    J'allais te pazser d'autres infos, je vais essayer ton idée....

  6. #6
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Private
    Cela semble fonctionner... j'affiche le nbre d'entrée dans le stack mais pas encore son contenu... c déjoà ça !

    Mais serait content et convaincu quand le contenu sera afficher

  7. #7
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut PRIVATE ET Class
    Bon, j'ai encore un souci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    			public function printStack()
    			{	
    user_error("printStack[".self::$cntStack."]" , E_USER_NOTICE) ;
    				for ($i = 0 ; $i < self::$cntStack ; $i++)
    703 ==>				user_error ("stack[".self::$cntStack."] - " . $this->stackMsg[$i] , E_USER_NOTICE) ;
    			}
    Log 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
    [28-May-2010 16:10:06] PHP Notice:  emptyStack[0] in F:\WebSites\test\checkform.php on line 695
    [28-May-2010 16:10:06] PHP Notice:  Start of Validation ==> cntStack[0] in F:\WebSites\test\checkform.php on line 731
    [28-May-2010 16:10:06] PHP Notice:  Start Validating field[0]  cntStack[0] in F:\WebSites\test\checkform.php on line 736
    [28-May-2010 16:10:06] PHP Notice:  +++++++ Stacking msg[1][Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] in F:\WebSites\test\checkform.php on line 688
    [28-May-2010 16:10:06] PHP Notice:  printStack[1] in F:\WebSites\test\checkform.php on line 701
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[1] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  End   Validating field[0]  cntStack[1] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:10:06] PHP Notice:  Start Validating field[1]  cntStack[1] in F:\WebSites\test\checkform.php on line 736
    [28-May-2010 16:10:06] PHP Notice:  +++++++ Stacking msg[2][Le champ[nom] doit avoir une longueur comprise entre 3 et 30] in F:\WebSites\test\checkform.php on line 688
    [28-May-2010 16:10:06] PHP Notice:  printStack[2] in F:\WebSites\test\checkform.php on line 701
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[2] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[2] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  End   Validating field[1]  cntStack[2] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:10:06] PHP Notice:  Start Validating field[2]  cntStack[2] in F:\WebSites\test\checkform.php on line 736
    [28-May-2010 16:10:06] PHP Notice:  +++++++ Stacking msg[3][Le champ[numero] doit avoir une longueur comprise entre 3 et 5] in F:\WebSites\test\checkform.php on line 688
    [28-May-2010 16:10:06] PHP Notice:  printStack[3] in F:\WebSites\test\checkform.php on line 701
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[3] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[3] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 2 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[3] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  End   Validating field[2]  cntStack[3] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:10:06] PHP Notice:  Start Validating field[3]  cntStack[3] in F:\WebSites\test\checkform.php on line 736
    [28-May-2010 16:10:06] PHP Notice:  Validating EMAIL[aaa.bbbddd.exxt] in F:\WebSites\test\checkform.php on line 289
    [28-May-2010 16:10:06] PHP Notice:  EMAIL Validating FILLED[aaa.bbbddd.exxt] in F:\WebSites\test\checkform.php on line 268
    [28-May-2010 16:10:06] PHP Notice:  EMAIL Validating CHKRANGE[15]-[8]-[30] in F:\WebSites\test\checkform.php on line 283
    [28-May-2010 16:10:06] PHP Notice:  +++++++ Stacking msg[4][Le champ[email] doit avoir un format comme: [aaa.]bbb@ccc.EXT !] in F:\WebSites\test\checkform.php on line 688
    [28-May-2010 16:10:06] PHP Notice:  printStack[4] in F:\WebSites\test\checkform.php on line 701
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 2 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 3 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:10:06] PHP Notice:  End   Validating field[3]  cntStack[4] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:10:06] PHP Notice:  End of Constructor[4] in F:\WebSites\test\checkform.php on line 662
    [28-May-2010 16:10:06] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 814
    [28-May-2010 16:10:06] PHP Notice:  getStackError[4] in F:\WebSites\test\checkform.php on line 676
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 681
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 681
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 2 in F:\WebSites\test\checkform.php on line 681
    [28-May-2010 16:10:06] PHP Notice:  Undefined offset: 3 in F:\WebSites\test\checkform.php on line 681
    Au moment où de ma forme je veux visualiser le contenu du stack, j'ai

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    			public function getStackError() 				// Public car function appelée fu formulaire...
    			{	
    user_error("getStackError[".self::$cntStack."]" , E_USER_NOTICE) ;	 
    				$str = "" ; 
    print("getStackError ==>[".self::$cntStack."]") ;
    //				print_r($this->stackMsg); 
    				for ($i = 0 ; $i < self::$cntStack ; $i++)
    681 ==>			$str .= $this->stackMsg[$i] ;
    				return($str) ; 
    			}
    Qui est le stack proprement dit, je dois le mettre en static aussi ?
    J'essaye....

    @+

  8. #8
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut PRIVATE
    Bof....
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    			public function printStack()
    			{	
    user_error("printStack[".self::$cntStack."]" , E_USER_NOTICE) ;
    				for ($i = 0 ; $i < self::$cntStack ; $i++)
    703 ==>			
    user_error ("stack[".self::$cntStack."] - " . self::$stackMsg[$i] , E_USER_NOTICE) ;
    			}
    et j'i mis aussi le Stack en static

    Le log:
    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
    [28-May-2010 16:22:12] PHP Notice:  stack[1] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  End   Validating field[0]  cntStack[1] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:22:12] PHP Notice:  Start Validating field[1]  cntStack[1] in F:\WebSites\test\checkform.php on line 736
    [28-May-2010 16:22:12] PHP Notice:  +++++++ Stacking msg[2][Le champ[nom] doit avoir une longueur comprise entre 3 et 30] in F:\WebSites\test\checkform.php on line 688
    [28-May-2010 16:22:12] PHP Notice:  printStack[2] in F:\WebSites\test\checkform.php on line 701
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[2] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[2] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  End   Validating field[1]  cntStack[2] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:22:12] PHP Notice:  Start Validating field[2]  cntStack[2] in F:\WebSites\test\checkform.php on line 736
    [28-May-2010 16:22:12] PHP Notice:  +++++++ Stacking msg[3][Le champ[numero] doit avoir une longueur comprise entre 3 et 5] in F:\WebSites\test\checkform.php on line 688
    [28-May-2010 16:22:12] PHP Notice:  printStack[3] in F:\WebSites\test\checkform.php on line 701
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[3] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[3] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 2 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[3] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  End   Validating field[2]  cntStack[3] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:22:12] PHP Notice:  Start Validating field[3]  cntStack[3] in F:\WebSites\test\checkform.php on line 736
    [28-May-2010 16:22:12] PHP Notice:  Validating EMAIL[aaa.bbbddd.exxt] in F:\WebSites\test\checkform.php on line 289
    [28-May-2010 16:22:12] PHP Notice:  EMAIL Validating FILLED[aaa.bbbddd.exxt] in F:\WebSites\test\checkform.php on line 268
    [28-May-2010 16:22:12] PHP Notice:  EMAIL Validating CHKRANGE[15]-[8]-[30] in F:\WebSites\test\checkform.php on line 283
    [28-May-2010 16:22:12] PHP Notice:  +++++++ Stacking msg[4][Le champ[email] doit avoir un format comme: [aaa.]bbb@ccc.EXT !] in F:\WebSites\test\checkform.php on line 688
    [28-May-2010 16:22:12] PHP Notice:  printStack[4] in F:\WebSites\test\checkform.php on line 701
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 2 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 3 in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  stack[4] -  in F:\WebSites\test\checkform.php on line 703
    [28-May-2010 16:22:12] PHP Notice:  End   Validating field[3]  cntStack[4] in F:\WebSites\test\checkform.php on line 740
    [28-May-2010 16:22:12] PHP Notice:  End of Constructor[4] in F:\WebSites\test\checkform.php on line 662
    [28-May-2010 16:22:12] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 814
    [28-May-2010 16:22:12] PHP Notice:  getStackError[4] in F:\WebSites\test\checkform.php on line 676
    
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 681
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 681
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 2 in F:\WebSites\test\checkform.php on line 681
    [28-May-2010 16:22:12] PHP Notice:  Undefined offset: 3 in F:\WebSites\test\checkform.php on line 681

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    			public function getStackError() 				// Public car function appelée fu formulaire...
    			{	
    user_error("getStackError[".self::$cntStack."]" , E_USER_NOTICE) ;	 
    				$str = "" ; 
    print("getStackError ==>[".self::$cntStack."]") ;
    //				print_r($this->stackMsg); 
    				for ($i = 0 ; $i < self::$cntStack ; $i++)
    681 ==>					$str .= self::$stackMsg[$i] ;
    				return($str) ; 
    			}
    Mais j'ai bien 4 entrées dans le stack de 0=>3...

    Pb presque résolu !

  9. #9
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Appel d'une propriété de ka forme HTML
    Question que je me pose quant à la ligne 681 et l'erreur qu'elle me donne.


    Est ce possible que la classe CheckForm que j'ai appelé au $_POST du bouton submit n'existe plus (quoique je ne l'ai pas explcitement supprimée) cela expliquerait peut être les 4 messages 681

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    
           $cf = new checkform($form);
       	if (isset($_POST['chkform']))
    		{	user_error("POST SUBMIT CATCHED" , E_USER_NOTICE) ;
    /*

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
      <tr>
        <td height="104">&nbsp;</td>
        <td colspan="6" align="center">
            <textarea name="textarea2" cols="70" rows="5"><?php echo $cf->getStackError()?></textarea>     </td>
        <td>&nbsp;</td>
      </tr>

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    			public function getStackError() 				// Public car function appelée fu formulaire...
    			{	
    user_error("getStackError[".self::$cntStack."]" , E_USER_NOTICE) ;	 
    				$str = "" ; 
    print("getStackError ==>[".self::$cntStack."]") ;
    //				print_r($this->stackMsg); 
    				for ($i = 0 ; $i < self::$cntStack ; $i++)
    681 ==>			$str .= self::$stackMsg[$i] ;
    				return($str) ; 
    			}

    On se rapproche de la solution mais on y est pas encore.....

  10. #10
    Membre Expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Par défaut
    As-tu également mis stackMsg en static ? Et l'as tu bien déclaré en tant que tableau dans ton constructeur, ou directement lors de sa déclaration ?

    Aussi, la solution que je t'ai donné est bien la bonne, ton problème est maintenant un simple problème d'occurence non définie :

    Pas bon :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    print_r($this->stackMsg);
    Bon (et que renvoie ceci ?)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    print_r(self::$stackMsg);

  11. #11
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Class architecture...
    Non, regarde les displays...

    [
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    28-May-2010 17:18:28] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 806
    [28-May-2010 17:18:28] PHP Notice:  getStackError[4] in F:\WebSites\test\checkform.php on line 686
    [28-May-2010 17:18:28] PHP Notice:  Undefined offset: 0 in F:\WebSites\test\checkform.php on line 691
    [28-May-2010 17:18:28] PHP Notice:  Undefined offset: 1 in F:\WebSites\test\checkform.php on line 691
    [28-May-2010 17:18:28] PHP Notice:  Undefined offset: 2 in F:\WebSites\test\checkform.php on line 691
    [28-May-2010 17:18:28] PHP Notice:  Undefined offset: 3 in F:\WebSites\test\checkform.php on line 691
    
    
    [28-May-2010 17:18:28] PHP Warning:  __destruct CATCHED in F:\WebSites\test\checkform.php on line 676
    Ces 4 messages arrivent avant que le destructeur est appelé !

    Ouf.....

  12. #12
    Membre Expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Par défaut
    À quoi correspond la ligne 691 ?

  13. #13
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut ClasS et oop
    Bien vu, ke tableau est tjs vide, print_r me donne array()...... dont c'est dans cette fonction que le problème se passe.
    Oui j'ai bien mis mon Stact en staitic ausssi.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    			public function stackMessage($msg)
    			{	 
    user_error("+++++++ Stacking msg[".self::$cntStack."][".$msg."]" , E_USER_NOTICE) ;	 
    				$this->stackMsg[self::$cntStack++] = $msg . "<br>\n" ; 
    print("Stacking[".$msg."] - cntStack[".self::$cntStack."]") ;
    			}
    On y arrive...... doucettement mais surement.....

  14. #14
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Trouvé
    Ok ne cherche plus, j'ai appliqué ton conseil quand à l'indice mais je dois l'appliquer aussi pour le tableau

    Donc dans le code précédent, on trouve:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    self::$stackMsg[self::$cntStack++] = $msg . "<br>\n" ;
    Ce qui va mieux et j'ai mon affichage HTML.....

    Et je n'ai plus ces 4 messages d'erreur...

    La journée a été bonne OUF......

    Grand merci à toi.....

  15. #15
    Membre Expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Par défaut
    Je t'en prie ca fait plaisir

    Bonne continuation.

  16. #16
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Merci
    Merci Thomas, le plaisir est partagé !

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

Discussions similaires

  1. [AC-2007] Mise en oeuvre des modules de classe de formulaire
    Par Triton972 dans le forum IHM
    Réponses: 1
    Dernier message: 26/01/2012, 20h25
  2. Classes et Formulaire
    Par wattaroo dans le forum Langage
    Réponses: 5
    Dernier message: 01/10/2010, 17h56
  3. Où placer les classes de formulaires ?
    Par littleman dans le forum Zend_Form
    Réponses: 5
    Dernier message: 12/09/2008, 13h09
  4. [Vb.net]_Héritage de classe sur formulaire
    Par Gdal dans le forum VB.NET
    Réponses: 3
    Dernier message: 26/03/2007, 19h19

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