CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 OnValidate Showing Errors, still inserting Record

Print topic Send  topic

Author Message
fotrane

Posts: 13
Posted: 04/06/2004, 12:17 PM

Perhaps I'm missing something very simple (semicolon theory), but I've been using CC/CCS for threee years and haven't had this problem yet.

I have a registration form, all fields required.
2 fields are set to "unique"
I have the following validation rules in place

1.) Checks strlen for each field, (validates required fields)
2.) Validates email
3.) Validates Password/Verify Password Match
4.) Obviously checks the 2 unique values do not exist in the database

If the form does have an error when the user submits, it returns and properly shows the error. However, upon resubmitting it, it returns yet again with an error stating that the record for [unique field] is already in the DB. Why is it inserting the record with validation in place? Is this a job for $form->InsertAllowed? Thoughts on this are much appreciated.

Steve
View profile  Send private message
peterr


Posts: 5971
Posted: 04/06/2004, 4:01 PM

One possibility is that your record isn't inserted but was already in the database. The initial error messages do not tell you about this because nothing is being inserted in the database and therefore the program doesn't know if the record is unique, until later when all fields are validated OK.
In other words - the field validation happens first and if successful then the record is inserted and finally the "Unique" error comes up. Therefore there are no logical indications that your record wasn't already in the database to begin with.

If you can confirm that the program indeed inserts the record even if validation fails, then it would be helpful to know how exactly is your validation performed. Are you using custom code for this? Could you paste it here?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
johny_f

Posts: 23
Posted: 04/06/2004, 11:25 PM

I had the same problems with some forms.
Frist time error check worked, but after resubmitting (simply pushing butto again) it just inserted the record.

It was considering cusomised "On validate" events.
(No unique issue in my from)


_________________
Johny_f
View profile  Send private message
peterr


Posts: 5971
Posted: 04/07/2004, 12:10 AM

Johnny,
You wrote that you had the same problem but then you described a completely different problem. The other user (Steve) wrote that during resubmitting (pushing the button again) the record cannot be inserted because it was already inserted earlier. I just want to clarify this to avoid later confusion or discussion of different topics under impression that they may be the same.
Thanks
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
fotrane

Posts: 13
Posted: 04/07/2004, 8:44 AM

Well, I think I may have foiund part of the problem, I just need to see about fixing it.... :-)

I have a two-part validation going on with this form. The first part is validating all form fields are wither present and/ot regExp validation on them (email).

I am trying to validate the second part only if part one is succesful. The secon d part consists of checking two fields against a second table, and if it finds a match, it will subnmit the form. If not, I want it to Display an error.

I have removed the default Error label and assigned each field it's own error control, using an OnValidate event for each field. If any of these fieds fail validation, I assign a variable called $missingfields:

global $register;
if (strlen($register->email->GetText()) && !preg_match("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $register->email->GetText()))
{
$register->email->Errors->addError("· Please enter a valid e-mail address <BR>(i.e. <i>user@yourhost.com</i>");
$missingfields = 1;
}


The last onValidate event does the SQL query based on whether or whether or not $missingfields is present.

Does this make any sense?

Steve
View profile  Send private message
peterr


Posts: 5971
Posted: 04/07/2004, 11:23 AM

Looks like you may be adding the error into a wrong component/control.
Similar issue was discussed here just a week ago: http://forums.codecharge.com/posts.php?post_id=44975
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
johny_f

Posts: 23
Posted: 04/07/2004, 11:16 PM

Sorry for confusing, I'd better read more carefully in the future.



_________________
Johny_f
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.