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 :

HTML à PHP; conversion [PHP 5.3]


Sujet :

Langage PHP

  1. #21
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML => PHP
    Je remets de l'ordre et je foire....

    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
    	class Form extends Stack
    	{	private $form, 	 $formValid, $check ;
    		private $action, $method, 	 $id, $name ;
    		private $tab_field = array() ;
    		
    /**
    * 		From constructor
    *
    */	
    		function __construct($action = NULL, $method = NULL, $id = NULL, $name = NULL) {   
    //		   	$this->initForm($form);
    			$this->action 	= $action ;
    			$this->method 	= $method ;
    		   	$this->name 	= $name ;
    		   	$this->id   	= $id ;
    //			var_dump($action,$method,$îd,$name) ;
    			$this->validate() ;
    		}				
    			
    		function __destruct()
    		{}
    			
    		function validate()
    		{	$this->action = ($this->action != NULL) ? $this->action : '$_SERVER[\'PHP_SELF\']';
    		   	$this->method = ($this->method != NULL) ? $this->method : 'POST';
    				 
    		    //
    			//   name OR id must be specified
    	 	    //   ============================
    	  	    if ((isset($this->id) && isset($this->name))) {
    		 	   user_error("NAME or ID Should be specified" , E_USER_ERROR);
    		   
    		    } elseif ( ! isset($this->id)) {
    			   $this->id = $this->name;
    		   
    		    } else {
    			   $this->name = $this->id;
    		    }
    			var_dump($this->action,$this->method,$this->îd,$this->name) ;
    		}
    			
    		private function initForm($form)
    		{   $this->form = $form ;
    			Stack::emptyStack() ;
    		}
    			
    /**
    * 		Form Start
    *
    */	
    		function start()
    		{	
    61==>	echo '<form action="'.$this->action.'" method="'.$this->method.'" name="'.$this->name.'" id="'.$this->id.'">' ;
    '		}
    Les var_dump sont inutiles car j'ai dans le log:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    PHP Parse error:  syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in F:\WebSites\date\class\form.php on line 61
    Je vais promener mon chien et méditer cela....
    Dsl, j'ai cru bien faire.....

  2. #22
    Membre émérite Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Points : 2 566
    Points
    2 566
    Par défaut
    Pas sur que ton problème soit résolu

    En effet ici :

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    if ((isset($id) && isset($name))) {
        user_error("NAME or ID Should be specified" , E_USER_ERROR);

    Littéralement tu lui dis : "si mes 2 variables $id et $name sont définies, alors je balance l'erreur comme quoi les 2 variables doivent être définies"

    C'est vraiment ce que tu veux faire...?

    EDIT: pour ton erreur à la ligne 61, c'est quoi ton guillemet simple qui est sous ton 61 ??

  3. #23
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML => PHP
    Bjr Madfrix;

    J'ai modifié ainsi

    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
    		function validate()
    		{	$this->action = ($this->action != NULL) ? $this->action : '$_SERVER[\'PHP_SELF\']';
    		   	$this->method = ($this->method != NULL) ? $this->method : 'POST';
    				 
    		    //
    			//   name OR id must be specified
    	 	    //   ============================
    	  	    if (!(isset($this->id) || isset($this->name))) {
    		 	   user_error("NAME or ID Should be specified" , E_USER_ERROR);
    		   
    		    } elseif ( ! isset($this->id)) {
    			   $this->id = $this->name;
    		   
    		    } else {
    			   $this->name = $this->id;
    		    }
    			var_dump($this->action,$this->method,$this->îd,$this->name) ;
    		}
    Mais j'ai dans le log:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    PHP Fatal error:  NAME or ID Should be specified in F:\WebSites\date\class\form.php on line 38
    Ce qui veut dire que $id && $name sont tous 2 == NULL....
    Et là, je ne pige plus....

    J'ai supprime la quote en dessous du 61....

    Merci

  4. #24
    Membre émérite Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Points : 2 566
    Points
    2 566
    Par défaut
    La flemme de relire tout mais j'ai vaguement vu que tu utilisais mal parfois les paramètres des fonctions. Peut être est ce le cas avec le constructeur ?

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    function __construct($action = NULL, $method = NULL, $id = NULL, $name = NULL) {  }

    Il faut par exemple pour instancier la propriété id et name de ton objet que tu appèle à minima ceci :

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $class = new Class(null, null, 10, 'nom');

    et pas comme ca :

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $class = new Class($id=10, $nom='nom');

    Peut être est ce ton erreur ?

    Fais voir où tu instancies ta classe

  5. #25
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML => PHP
    Voici le principal de ma classe

    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
     
    	class Form extends Stack
    	{	private $form, 	 $formValid, $check ;
    		private $action, $method, 	 $id, $name ;
    		private $tab_field = array() ;
     
    /**
    * 		Constructor
    *		===========
    */	
    		function __construct($action = NULL, $method = NULL, $id = NULL, $name = NULL) {   
    //		   	$this->initForm($form);
    			$this->action 	= $action ;
    			$this->method 	= $method ;
    		   	$this->name 	= $name ;
    		   	$this->id   	= $id ;
    			var_dump($id,$name) ;
    			$this->validator() ;
    		}				
     
    /**
    * 		Destructor
    *		==========
    */	
    		function __destruct()
    		{}
     
    /**
    * 		Validator
    *		=========
    */	
    		function validator()
    		{	$this->action = ($this->action != NULL) ? $this->action : '$_SERVER[\'PHP_SELF\']';
    		   	$this->method = ($this->method != NULL) ? $this->method : 'POST';
     
    		    //
    			//   name OR id must be specified
    	 	    //   ============================
    	  	    if (!(isset($this->id) || isset($this->name))) {
    		 	   user_error("NAME or ID Should be specified" , E_USER_ERROR);
     
    		    } elseif ( ! isset($this->id)) {
    			   $this->id = $this->name;
     
    		    } else {
    			   $this->name = $this->id;
    		    }
    			var_dump($this->action,$this->method,$this->îd,$this->name) ;
    		}
     
    		private function initForm($form)
    		{   $this->form = $form ;
    			Stack::emptyStack() ;
    		}
     
    /**
    * 		Start
    *		=====
    */	
    		function start()
    		{	
    			echo '<form action="'.$this->action.'" method="'.$this->method.'" name="'.$this->name.'" id="'.$this->id.'">' ;
    //			echo '<form action="/index.php" method="post" name="'.$this->name.'" id="'.$this->id.'">' ;
    // 			echo "<form action='/index.php' method='post' name='.$this->name.' id='.$this->id.'>" ;   
    		}
     
    /**
    * 		End
    *		===
    */	
    		function end()
    		{	echo "</form>" ;   	}
    et l'instanciation... dans le fichier index.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
    	$form 		= new Form($name = "test");
    	$birthdate 	= new Date (  "naissance"	,   MUST    ,   "Date de naissance"                 ,   TODAY              			) ;
    	$birthdate->setDefault() ;
    //  	$birthdate->debug() ;
    /**
    *	Interception du bouton SUBMIT
    *	=============================
    */	
       	if (isset($_POST['Submit']))
    		{//	if ($this->debug)
    				user_error("POST SUBMIT CATCHED" , E_USER_NOTICE) ;
     			if ($birthdate->isFieldValid())
    				{	# Formulaire valide
        				# =================
    					$result = $birthdate->getFieldValue() ;
     					$msg    = "Date Valide[$result]" ;
        			}
         		else 
    				{	# Formulaire invalide
        				# ===================
    					$msg    = "Date Invalide ! " ;
    				}
    			user_error($msg, E_USER_NOTICE) ;
        	}
    	else
    		$msg = "Entrez la date !" ;
    
    et je sors sans le log le msg comme quoi name && id sont nulls, alors que pour moi, j'ai $name="test"....

  6. #26
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML => PHP
    Ce qui revient à dire, et cela fonctionne, que si je fais

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $form 		= new Form(NULL,NULL,NULL,"test");
    que les paramètres nominatifs (ou positionnels) tels que $param="value" ne servent à rien en PHP puisque je dois TOUS les définir dans l'instanciation
    AUSSI !!!!!

  7. #27
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML => PHP
    J'arrête un peu car la grosse tête...

    Mon index.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
     
    	$form 		= new Form(NULL,NULL,NULL,"test");
    	$birthdate 	= new Date (  "naissance"	,   MUST    ,   "Date de naissance"                 ,   TODAY              			) ;
    	$birthdate->setDefault() ;
    //  	$birthdate->debug() ;
    /**
    *	Interception du bouton SUBMIT
    *	=============================
    */	
       	if (isset($_POST['Submit']))
    		{//	if ($this->debug)
    				user_error("POST SUBMIT CATCHED" , E_USER_NOTICE) ;
     			if ($birthdate->isFieldValid())
    				{	# Formulaire valide
        				# =================
    					$result = $birthdate->getFieldValue() ;
     					$msg    = "Date Valide[$result]" ;
        			}
         		else 
    				{	# Formulaire invalide
        				# ===================
    					$msg    = "Date Invalide ! " ;
    				}
    			user_error($msg, E_USER_NOTICE) ;
        	}
    	else
    		$msg = "Entrez la date !" ;
    et ma classe Form

    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
     
    require_once $_SERVER['DOCUMENT_ROOT'] . "/class/stack.php";     
     
    	class Form extends Stack
    	{	private $form, 	 $formValid, $check ;
    		private $action, $method, 	 $id, $name ;
    		private $tab_field = array() ;
     
    /**
    * 		Constructor
    *		===========
    */	
    		function __construct($action = NULL, $method = NULL, $id = NULL, $name = NULL) {   
    //		   	$this->initForm($form);
    			$this->action 	= $action ;
    			$this->method 	= $method ;
    		   	$this->name 	= $name ;
    		   	$this->id   	= $id ;
    			var_dump($id,$name) ;
    			$this->validator() ;
    		}				
     
    /**
    * 		Destructor
    *		==========
    */	
    		function __destruct()
    		{}
     
    /**
    * 		Validator
    *		=========
    */	
    		function validator()
    		{	$this->action = ($this->action != NULL) ? $this->action : '$_SERVER[\'PHP_SELF\']';
    		   	$this->method = ($this->method != NULL) ? $this->method : 'POST';
     
    		    //
    			//   name OR id must be specified
    	 	    //   ============================
    	  	    if (!(isset($this->id) || isset($this->name))) {
    		 	   user_error("NAME or ID Should be specified" , E_USER_ERROR);
     
    		    } elseif ( ! isset($this->id)) {
    			   $this->id = $this->name;
     
    		    } else {
    			   $this->name = $this->id;
    		    }
    			var_dump($this->action,$this->method,$this->îd,$this->name) ;
    		}
     
    		private function initForm($form)
    		{   $this->form = $form ;
    			Stack::emptyStack() ;
    		}
     
    /**
    * 		Start
    *		=====
    */	
    		function start()
    		{	echo '<form action="'.$this->action.'" method="'.$this->method.'" name="'.$this->name.'" id="'.$this->id.'">' ;		}
     
    /**
    * 		End
    *		===
    */	
    		function end()
    		{	echo "</form>" ;   	}
    Mais cela commence à me gonfler....

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Not Found
     
    The requested URL /$_SERVER['PHP_SELF'] was not found on this server.
    Stop mes neurones comateuses rendent l'âme pour l'instant...

    et pourtant mon var_dump m'affiche bien:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    string(20) "$_SERVER['PHP_SELF']" string(4) "POST" NULL string(4) "test"
    Merci

  8. #28
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML => PHP
    Je ne suis pas dans ton dernier message... (paramètres positionnels)...

    Mon dernier post contient le tout...
    Dsl mais je DOIS arrêter une bonne heure....


  9. #29
    Membre émérite Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Points : 2 566
    Points
    2 566
    Par défaut
    The requested URL /$_SERVER['PHP_SELF'] was not found on this server.
    Que donne le code source généré par ta classe ?

  10. #30
    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
    Points : 44 155
    Points
    44 155
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $this->action = ($this->action != NULL) ? $this->action : $_SERVER['PHP_SELF'];
    Sinon l'action vaut litteralement $_SERVER['PHP_SELF'] et non pas sa valeur.

  11. #31
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML -> PHP
    Merci Sabotage, ton pseudo ne te ressemble pas

    C'est un facette de PHP que j'ai difficile à appréhender moi qui vient de l'informatique classique des années 70....

    Meilleurs voeux

  12. #32
    Membre émérite Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Points : 2 566
    Points
    2 566
    Par défaut
    Citation Envoyé par ETVigan Voir le message
    C'est un facette de PHP que j'ai difficile à appréhender moi qui vient de l'informatique classique des années 70....
    Espèce de vieux !

  13. #33
    Débutant 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
    Points : 170
    Points
    170
    Par défaut HTML -> PHP
    Vieux mais peut être pas croulant même si mon coma ne m'a pas arrangé la concentration; l’assimilation et les heures de travail que je dois absolument interrompre avant de recommencer....

    P'tit jeune qui ne sait encore rien.....

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. [PHP 5.3] Conseil pour conversion HTML - PHP
    Par ETVigan dans le forum Langage
    Réponses: 9
    Dernier message: 21/04/2011, 14h21
  2. [XSLT][PHP]conversion balise html
    Par abdoulax dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 11/10/2006, 11h34
  3. [HTML][PHP] Les liens href...
    Par hackrobat dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 31/03/2005, 11h28

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