Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > PEAR > HTML_quickform
HTML_quickform Forum d'entraide pour la bibliothèque HTML_quickform du framework PEAR, permettant de manipuler des formulaires en PHP. Avant de poster -> tutoriels QuickForm
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 18/01/2008, 12h23   #1
Membre éprouvé
 
Avatar de Katachana
 
Inscription : avril 2007
Messages : 745
Détails du profil
Informations personnelles :
Localisation : France, Loire Atlantique (Pays de la Loire)

Informations forums :
Inscription : avril 2007
Messages : 745
Points : 440
Points : 440
Par défaut [QuickForm] Utilisation de la bibliothèque QuickForm

Voila la structure de mes fichiers :

S'il y a des erreurs dans le code , cela est du a des suppressions lors de l'insertion dans ce post un peu trop rapide

conf.php
Code :
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
<?
 
 
	#Pear library
	require_once "HTML/QuickForm.php";
	require_once 'HTML/QuickForm/select.php';
	require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
	$form = new HTML_QuickForm('form_masse','post');
 
	#Path to the configuration dir
	global $path;
	$path = "./modules/xxx/";
 
	#PHP functions
	require_once $path."DB-Func.php";
 
	# Smarty template Init
	$tpl = new Smarty();
	$tpl = initSmartyTpl($path, $tpl);
 
	$tpl->assign("SPEEDYCONF_URL", $url);
	$tpl->assign("SPEEDYCONF_TITLE", $lang["sc_title"]);
 
	$form->addElement('file','conf_1',$lang['sc_conf_masse_titre_1']);
 
	$form->addRule('conf_1', 'Vous devez renseigner le champ', 'required');
 
	//Ajout de code supplémentaire
	if ($form->validate()) {
      # If the form validates then freeze the data
      $form->freeze();
   }
	 // Create the renderer object
	$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);
 
  // build the HTML for the form
	$form->accept($renderer);
 
	// assign array with form data
	$tpl->assign('form', $renderer->toArray());	
 
	$tpl->assign('o', $o);
	$tpl->assign('use_lca', $use_lca);
 
	// parse and display the template
	$tpl->display("sc_conf_masse.ihtml");
?>
conf.ihtml
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<form {$form.attributes} enctype="multipart/form-data">
 
<div id='tab1' class='tab'>
 <table id="ListTable">
 	<tr class="ListHeader"><td class="ListColHeaderLeft" colspan="2" ><img src='./img/icones/16x16/clients.gif'> {$SPEEDYCONF_TITLE}</td></tr>
 
	      <tr class="list_lvl_1"><td width="100%" class="ListColLeft" colspan="2">&nbsp;</td></tr>		
				<tr class="list_one"><td class="ListColLeft" colspan="2">&nbsp;</td></tr>	       		
				<tr class="list_two"><td class="FormRowField">{$form.conf_1.label}</td><td class="FormRowValue">{$form.conf_1.html}&nbsp;&nbsp;{$SC_CONF_MASSE_INFO_1}</td></tr>		
  </table>
</div>
 
<div id="validForm">
  <p class="oreonbutton">{$form.submit.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</td></p>
</div>
 
 {$form.hidden}
</form>

DB-Func.php
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?
 
function testHostExistenceSC ($name = NULL){
		global $pearDB;
                $DBRESULT =& $pearDB->query("SELECT host_name, host_id FROM host WHERE host_name = '".htmlentities($name, ENT_QUOTES)."'");
                if (PEAR::isError($DBRESULT))
                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br>";
                $host =& $DBRESULT->fetchRow();
                if ($DBRESULT->numRows() >= 1 ){
			$DBRESULT->free();
                        return false;
		}
                else {
			$DBRESULT->free();
                        return true;
		}
}
.......................................
>

Je débute completement en php et doit faire rapidement du re use (délais tres court de conception).

Je ne comprend pas ce qui fait le lien entre la page conf.php et DB-Func.php ?
Si l'on veux passer en parametres d'un fonction présent dans DB-Func.php des variable précise obtenu dans le form de conf.php , comment faire le lien ?


Merci bcp d'avance , je sais que ce genre de question basique a tendance a énerver certains mais je suis completement pris par le temps..
Katachana est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/01/2008, 16h01   #2
Membre chevronné
 
Avatar de Dia_FR
 
Homme Aurélien
Développeur Web
Inscription : avril 2006
Messages : 510
Détails du profil
Informations personnelles :
Nom : Homme Aurélien
Localisation : France

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : avril 2006
Messages : 510
Points : 643
Points : 643
Citation:
Envoyé par Katachana Voir le message
Je ne comprend pas ce qui fait le lien entre la page conf.php et DB-Func.php ?
dans conf.php :
Code :
require_once $path."DB-Func.php";
Citation:
Envoyé par Katachana Voir le message
Si l'on veux passer en parametres d'un fonction présent dans DB-Func.php des variable précise obtenu dans le form de conf.php , comment faire le lien ?
quand tu fais ton include, tu prends le contenu du fichier et tu l'inclus dans la page courante donc dans conf.php tu peux appeler les fonctions présentes dans db-func.php comme si elles étaient écrites dans conf.php
__________________
Dia [ Page DVP ] [ Blog ] [ Site pro ]
Dia_FR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/01/2008, 16h15   #3
Membre éprouvé
 
Avatar de Katachana
 
Inscription : avril 2007
Messages : 745
Détails du profil
Informations personnelles :
Localisation : France, Loire Atlantique (Pays de la Loire)

Informations forums :
Inscription : avril 2007
Messages : 745
Points : 440
Points : 440
Merci !
Katachana est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 07h04.


 
 
 
 
Partenaires

Hébergement Web