Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Probleme de transmission de variables PHP > Template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
chamalo
Smarty Rookie


Joined: 22 Jul 2008
Posts: 12

PostPosted: Tue Jul 22, 2008 3:41 pm    Post subject: Probleme de transmission de variables PHP > Template Reply with quote

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
View user's profile Send private message
arnogb69
Smarty Rookie


Joined: 07 May 2008
Posts: 11

PostPosted: Wed Jul 23, 2008 9:23 am    Post subject: Reply with quote

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 Very Happy )

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
View user's profile Send private message
chamalo
Smarty Rookie


Joined: 22 Jul 2008
Posts: 12

PostPosted: Mon Jul 28, 2008 8:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP