|
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 |
adamos Smarty Rookie
Joined: 29 Dec 2004 Posts: 8 Location: Poland
|
Posted: Wed Dec 29, 2004 9:16 am Post subject: 2 forms and problem with SmartyValidate |
|
|
I have 2 forms, in with i use an engine form tutorial:
form 1:
[php:1:b1f4473aba]<?php
if(SmartyValidate::is_valid($_POST)) {
if (register_user($db, TABLE_USERS, $_POST)){
SmartyValidate::disconnect();
$smarty->assign("insert", True);
$smarty->assign("user_date", $_POST);
$body = $smarty->fetch("register.tpl");
}
else{
SmartyValidate::disconnect();
$body = $smarty->fetch("register.tpl");
}
}
else{
$smarty->assign($_POST);
$body = $smarty->fetch("register.tpl");
}
?>[/php:1:b1f4473aba]
and form2 is very similar.
Validatione works very good but I have a problem - when i do a validation in first form1 (click the submit button) and smartyvalidate send messages that any input field is incorrect and next a go to other form2, I see that validation is gooing even i don't click submit - so when i go to form2 valitadion is going automatucali when all field are empty, so when a onlu go to form.
I saw thet variable $_SESSION when a go from one form to other is fill by variable from form1.
So, Does exist any way to reset forms or that many forms work independently, because in this problem even I fill form up good variable SmartyValidation don't work - form return all field that I fill - and does not happend.
I please for help. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 29, 2004 3:04 pm Post subject: |
|
|
Are you testing !empty($_POST) before running it against is_valid() ? If so, that might be the problem on the second form, since $_POST may still contain values from the first form post. |
|
Back to top |
|
adamos Smarty Rookie
Joined: 29 Dec 2004 Posts: 8 Location: Poland
|
Posted: Thu Dec 30, 2004 9:09 am Post subject: |
|
|
tahnks, I resolved this problem - used this code:
[php:1:7ebaa262b0]<?php
if(empty($_POST)) {
SmartyValidate::connect($smarty, true);
...
}
?>[/php:1:7ebaa262b0]
So, reset old session data - I find this on this forum |
|
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
|