setQuery($query);$count = $db->loadResult();if ( $count = 0 ) { $form->validation_errors['input_username'] = "Member Nbr or Email does not exist, or they do not match."; return false;}?>I placed an event loop in the On Fail area of the Custom Validation Event and now the form fails the validation every time however no validation error appears after the Event Loop.This behaviour is the same whether I enter a valid combination or not. I have confirmed with phpMySQL that I have a row containing the pair of values I am entering and the SQL (with appropriate values substituted) returns the row.I placed a Debugger in there and got this:Data Array: Array( [chronoform] => GFA_Registration [event] => submit [option] => com_chronoforms [Itemid] => [input_mbr_name] => Tim Shirley [input_username] => M-13287 [input_email] => xxxx@yyy.com [input_password] => zzzzz [input_password_v] => zzzzz [input_submit_7] => Submit [4c8084541de1b08e1015bc06b62d5665] => 1 [name] => Tim Shirley [username] => M-13287 [email] => xxxx@yyy.com [password] => zzzzz [password2] => zzzzz [_PLUGINS_] => Array ( [joomla_registration] => Array ( [*isRoot] => [id] => 432 [name] => Tim Shirley [username] => M-13287 [email] => xxxx@yyy.com [password] => 3761d623af0edc5719a3053386fd4df9:xFX0cv07W9IyQOUTvzee8OywClrI4jrd [password_clear] => zzzzz [usertype] => deprecated [block] => 1 [sendEmail] => 0 [registerDate] => 2014-05-05 00:19:21 [lastvisitDate] => [activation] => 8ef5e5b831bab240fc35ad9ed9127caf [groups] => Array ( [0] => 2 ) [lastResetTime] => [resetCount] => [*_params] => JRegistry Object ( [data:protected] => stdClass Object ( ) ) [*_authGroups] => Array ( [0] => 1 ) [*_authLevels] => Array ( [0] => 1 [1] => 1 ) [*_authActions] => [*_errorMsg] => [*_errors] => Array ( ) [aid] => 0 [chronoform] => GFA_Registration [event] => submit [option] => com_chronoforms [Itemid] => [input_mbr_name] => Tim Shirley [input_username] => M-13287 [input_email] => xxxx@yyy.com [input_password] => zzzzz [input_password_v] => zzzzz [input_submit_7] => Submit [4c8084541de1b08e1015bc06b62d5665] => 1 [password2] => zzzzz ) ) [User] => Array ( [*isRoot] => [id] => 432 [name] => Tim Shirley [username] => M-13287 [email] => xxxx@yyy.com [password] => 3761d623af0edc5719a3053386fd4df9:xFX0cv07W9IyQOUTvzee8OywClrI4jrd [password_clear] => zzzzz [usertype] => deprecated [block] => 1 [sendEmail] => 0 [registerDate] => 2014-05-05 00:19:21 [lastvisitDate] => [activation] => 8ef5e5b831bab240fc35ad9ed9127caf [groups] => Array ( [0] => 2 ) [lastResetTime] => [resetCount] => [*_params] => JRegistry Object ( [data:protected] => stdClass Object ( ) ) [*_authGroups] => Array ( [0] => 1 ) [*_authLevels] => Array ( [0] => 1 [1] => 1 ) [*_authActions] => [*_errorMsg] => [*_errors] => Array ( ) [aid] => 0 [chronoform] => GFA_Registration [event] => submit [option] => com_chronoforms [Itemid] => [input_mbr_name] => Tim Shirley [input_username] => M-13287 [input_email] => xxxx@yyy.com [input_password] => zzzzz [input_password_v] => zzzzz [input_submit_7] => Submit [4c8084541de1b08e1015bc06b62d5665] => 1 [password2] => zzzzz ))Validation Errors: Array()So I am puzzled. 1. Why would this code always return a fail?2. Why does the error message not appear, since the code is failing?CheersTim"> Custom VaServer Side Validation - Forums

Forums

Custom VaServer Side Validation

tshirley 05 May, 2014
Hello,

I have a custom user registration form and I wish to only allow existing members of my organisaton to register. I have a table loaded with current member details including Member_Nbr (the registration username and email, and the idea was to use a Custom Server Side validation to search for a the member record and confirm that the email address is the same.

I created the basic form with no Validation, it works fine with no validation event.

Then I dragged a Custom Server Side Validation into the On Submit action and added the following:

<?php
$db =& JFactory::getDBO();
$query = "
  SELECT COUNT *
    FROM `#__glid_chronoforms_data_Member_Profile`
    WHERE `Member_Nbr` = '{$form->data['input_username]}' AND
                  'Email' = '{$form->data['input_email']}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count = 0 ) {
  $form->validation_errors['input_username'] = "Member Nbr or Email does not exist, or they do not match.";
  return false;
}
?>


I placed an event loop in the On Fail area of the Custom Validation Event and now the form fails the validation every time however no validation error appears after the Event Loop.

This behaviour is the same whether I enter a valid combination or not. I have confirmed with phpMySQL that I have a row containing the pair of values I am entering and the SQL (with appropriate values substituted) returns the row.

I placed a Debugger in there and got this:

Data Array: 
Array
(
    [chronoform] => GFA_Registration
    [event] => submit
    [option] => com_chronoforms
    [Itemid] => 
    [input_mbr_name] => Tim Shirley
    [input_username] => M-13287
    [input_email] => xxxx@yyy.com
    [input_password] => zzzzz
    [input_password_v] => zzzzz
    [input_submit_7] => Submit
    [4c8084541de1b08e1015bc06b62d5665] => 1
    [name] => Tim Shirley
    [username] => M-13287
    [email] => xxxx@yyy.com
    [password] => zzzzz
    [password2] => zzzzz
    [_PLUGINS_] => Array
        (
            [joomla_registration] => Array
                (
                    [*isRoot] => 
                    [id] => 432
                    [name] => Tim Shirley
                    [username] => M-13287
                    [email] => xxxx@yyy.com
                    [password] => 3761d623af0edc5719a3053386fd4df9:xFX0cv07W9IyQOUTvzee8OywClrI4jrd
                    [password_clear] => zzzzz
                    [usertype] => deprecated
                    [block] => 1
                    [sendEmail] => 0
                    [registerDate] => 2014-05-05 00:19:21
                    [lastvisitDate] => 
                    [activation] => 8ef5e5b831bab240fc35ad9ed9127caf
                    [groups] => Array
                        (
                            [0] => 2
                        )

                    [lastResetTime] => 
                    [resetCount] => 
                    [*_params] => JRegistry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                        )

                    [*_authGroups] => Array
                        (
                            [0] => 1
                        )

                    [*_authLevels] => Array
                        (
                            [0] => 1
                            [1] => 1
                        )

                    [*_authActions] => 
                    [*_errorMsg] => 
                    [*_errors] => Array
                        (
                        )

                    [aid] => 0
                    [chronoform] => GFA_Registration
                    [event] => submit
                    [option] => com_chronoforms
                    [Itemid] => 
                    [input_mbr_name] => Tim Shirley
                    [input_username] => M-13287
                    [input_email] => xxxx@yyy.com
                    [input_password] => zzzzz
                    [input_password_v] => zzzzz
                    [input_submit_7] => Submit
                    [4c8084541de1b08e1015bc06b62d5665] => 1
                    [password2] => zzzzz
                )

        )

    [User] => Array
        (
            [*isRoot] => 
            [id] => 432
            [name] => Tim Shirley
            [username] => M-13287
            [email] => xxxx@yyy.com
            [password] => 3761d623af0edc5719a3053386fd4df9:xFX0cv07W9IyQOUTvzee8OywClrI4jrd
            [password_clear] => zzzzz
            [usertype] => deprecated
            [block] => 1
            [sendEmail] => 0
            [registerDate] => 2014-05-05 00:19:21
            [lastvisitDate] => 
            [activation] => 8ef5e5b831bab240fc35ad9ed9127caf
            [groups] => Array
                (
                    [0] => 2
                )

            [lastResetTime] => 
            [resetCount] => 
            [*_params] => JRegistry Object
                (
                    [data:protected] => stdClass Object
                        (
                        )

                )

            [*_authGroups] => Array
                (
                    [0] => 1
                )

            [*_authLevels] => Array
                (
                    [0] => 1
                    [1] => 1
                )

            [*_authActions] => 
            [*_errorMsg] => 
            [*_errors] => Array
                (
                )

            [aid] => 0
            [chronoform] => GFA_Registration
            [event] => submit
            [option] => com_chronoforms
            [Itemid] => 
            [input_mbr_name] => Tim Shirley
            [input_username] => M-13287
            [input_email] => xxxx@yyy.com
            [input_password] => zzzzz
            [input_password_v] => zzzzz
            [input_submit_7] => Submit
            [4c8084541de1b08e1015bc06b62d5665] => 1
            [password2] => zzzzz
        )

)
Validation Errors: 
Array
(
)

So I am puzzled.

1. Why would this code always return a fail?
2. Why does the error message not appear, since the code is failing?

Cheers

Tim
Max_admin 05 May, 2014
Hi Tim,

Answers:

#1- Please try changing
if($count = 0)
to
if(empty($count))

#2- please change
$form->validation_errors
to
$form->errors
because this is v5

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
tshirley 05 May, 2014
Thank you

I tried this but with the same result. 😟

The on fail triggered both with valid and invalid data, and no validation errors appeared.

Cheers

Tim
GreyHead 05 May, 2014
Hi Tim,

I spotted a couple of things here last night then had internet connections.

+ It should be COUNT(*)

+ And if ( $count == 0 ) { or better if ( $count < 1 ) {

I suspect that the error message may be from some security protection on the server that is checking for SQL in the $_POST array.

Bob
tshirley 05 May, 2014
The error was indeed a setting in RSFirewall being a bit over-protective!

I will try it with COUNT (*)

Do I need a field to display the $form->errors result or will this appear in a black box as other validation errors?

Thanks heaps

Tim
Max_admin 05 May, 2014

Do I need a field to display the $form->errors result or will this appear in a black box as other validation errors?


No, they should auto display in red box above the form!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
tshirley 06 May, 2014
Thanks,

No luck so far - it is still 100% failing, whether the input is valid or not, and giving no error message.

<?php
$db =& JFactory::getDBO();
$query = "
  SELECT COUNT (*)
    FROM `#__glid_chronoforms_data_Member_Profile`
      WHERE 'Member_Nbr' = '{$form->data['input_username]}' AND
                  'Email' = '{$form->data['input_email']}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count < 1 ) {
   $form->errors['input_username'] = "Member Nbr or Email does not      exist, or they do not match.";
  return false;
}
?>


I do know that the field names are correct both on the database and the forms side, and that the query does return the correct rows if translated to phpMyadmin.

The form has this code in a Custom Server Side Validation event which is the first event inside OnSubmit. The On Fail has an Event Loop which is definitely triggering, and looping back to the form but with no error.

I can't see any errors in the code.

If someone I trust is able to have a look at it I can pm the admin credentials.

Cheers

Tim
Max_admin 06 May, 2014
Hi Tim,

There was a mistake, you have v4 and so you should actually use:
$form->validation_errors

I suggest that you add
echo $count
in order to check the result in both cases.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 07 May, 2014
HI Tim,

Just spotted another little problem. You have MySQL column names quoted with straight quotes. They need to be back-ticks e.g. `Member_Nbr` not 'Member_Nbr'.

Bob
This topic is locked and no more replies can be posted.