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

2 forms and problem with SmartyValidate

 
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 -> Add-ons
View previous topic :: View next topic  
Author Message
adamos
Smarty Rookie


Joined: 29 Dec 2004
Posts: 8
Location: Poland

PostPosted: Wed Dec 29, 2004 9:16 am    Post subject: 2 forms and problem with SmartyValidate Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Dec 29, 2004 3:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
adamos
Smarty Rookie


Joined: 29 Dec 2004
Posts: 8
Location: Poland

PostPosted: Thu Dec 30, 2004 9:09 am    Post subject: Reply with quote

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 Smile
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 -> Add-ons 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