|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
chamalo Smarty Rookie
Joined: 22 Jul 2008 Posts: 12
|
Posted: Tue Jul 22, 2008 3:41 pm Post subject: Probleme de transmission de variables PHP > Template |
|
|
Bonjour, j ai un probleme que je ne comprend pas...
Je recupere la valeur d'une checkbox decrite dans mon fichier tpl, mon fichier php la lit et l'assigne en tant que variable smarty
et aucun probleme pour la recuperer ensuite dans mon fichier tpl
Par contre j'aimerais pouvoir tester la valeur de ma checkbox (cas ou celle ci a ete coché et cas ou celle ci n a pas ete coché)
Donc je met un bete if(!empty($_POST)) le test est bon, les echos test que j ai mis dedans sont affichés, mais ma variable smarty n est plus assignée... bref je comprend pas pourquoi
voila mon code php
------------------------------------------------------------
if (isset($_POST['author_fedex']))
{
//echo "1";
if(!empty($_POST['author_fedex']))
{
//echo "2";
$smarty->assign('etatfedex', 'check');
}
else
{
echo "3";
$smarty->assign('etatfedex', 'uncheck');
}
}
Voila mon code TPL
----------------------------------------------------------------
{$etatfedex}
<br><br><input type='checkbox' name='author_fedex' Onchange="document.cartform.submit()" {if $etatfedex=='check'}checked{/if}>I authorize</input>
{$etatfedex}
C est vraiment bizarre comme probleme... si quelqu'un y comprend quelque chose, il me sauve ma journée!
Merci d avance!
Chamalo |
|
Back to top |
|
arnogb69 Smarty Rookie
Joined: 07 May 2008 Posts: 11
|
Posted: Wed Jul 23, 2008 9:23 am Post subject: |
|
|
Salut Chamalo,
J'ai testé ton code chez moi, et il fonctionne parfaitement.
La seule différence est que j'ai remplacé $_POST par $_GET (je ne voulais pas recréer un formulaire pour tester )
Je pense donc que ton erreur se situe par là, dans la validation de ta variable $_POST['author_fedex']. Tu devrais vérifier que tu la passes correctement et que tu la récupères bien...
Dis moi si cela t'a aidé |
|
Back to top |
|
chamalo Smarty Rookie
Joined: 22 Jul 2008 Posts: 12
|
Posted: Mon Jul 28, 2008 8:48 pm Post subject: |
|
|
Effectivement ca marchait bien, c etait juste que la page tpl se rechargeait 2 fois dans le code php, et que donc la variable se perdait au deuxieme chargement!
Merci beaucoup |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|