Support Forum

Every time that you post a problem, PLEASE add the Joomla and the extension's versions and revisions (for example: Joomla 3.3.6, Contact Enhanced 3.3.5), PHP version and Server's Operating System. If you only manage only one site it is easier if you edit your profile and just add that information to your signature. Don't forget to add a detailed description of the problem. If possible, write down all steps to simulate the problem.

Before submitting a new post, PLEASE make sure you are running the latest version, test in different browsers (IE, FF, Chrome,..) and clear Joomla and browser's cache after every change you make.

Also, most questions are already answered in our FAQ and in iFAQ and Contact Enhanced documentation pages.

× Contact Enhanced is a contact component manager created to replace Joomla! core contacts component and add lots of advantages and new features (see Features ) and it offers many plugins and modules for several different purposes,
Product page | Documentation Page

server-side validation to reject invalid phone number (example needed)

1 year 4 months ago #26626 by bcraigie
I have had a look at plugins/contactenhanced/customcode/code/onSubmitContact/example-onEmptySubject.php to try and make a copy of it that can detect if a spammer has typed in the site's phone number in the phone number field so I can reject the form, or even a blank phone number and somehow evaded the frontend javascript checking.

None of the example scripts are set up to reject a form. They all do some sort of modification of a field and continue to accept the form.

What do I need to do to reject a form submission? The code mentions $exception but isn't clear how to use it.

For example:
try
{
        $phone_number = $jinput->getString('phone_number', '');
 
        if (empty($phone_number))
        {
                //reject a blank phone number
        }
 
}
catch (Exception $e)
{
        $return = $e;
}
What code do I put in the //reject a blank phone number section to make it send an error message back to the user and to reject the form submission please?

The php documentation for PHP8 suggeststo me that something like this would work:
throw new Exception('Invalid phone number.');

But where does $exception come into it?

Thanks!

Brian

Please Log in or Create an account to join the conversation.

1 year 4 months ago #26627 by support
Dear Brian,

Which Joomla and Contact Enhanced versions are you using?

Best regards,

Please Log in or Create an account to join the conversation.

1 year 4 months ago #26629 by bcraigie
Hi Douglas. Joomla 4.2.2 with the latest CE 4.2

Thanks :-)

Please Log in or Create an account to join the conversation.

1 year 4 months ago #26630 by support
Brian,

I found the problem and fixed it in the new version I have just released.

Also, I have included an example in the package for the phone number. Just don't forget to rename the file, so it won't be overridden when you update next time.

Best regards,

Please Log in or Create an account to join the conversation.

1 year 4 months ago #26633 by bcraigie
Thank you so much Douglas. I see the example and it is excellent. I will copy that and test it out. :cheer:

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

Copyright © 2018 IdealExtensions.com. All Rights Reserved.

This site is not affiliated with or endorsed by the Joomla!™ Project. It is not supported or warranted by the Joomla!™ Project or Open Source Matters™. The Joomla!™ logo is used under a limited license granted by Open Source Matters™, the trademark holder in the United States and other countries.
We may collect your IP address and your browser's User Agent string while using our site for security reasons and deriving aggregate information (analytics). This information is retained for a minimum of 1 and a maximum of 24 months.
Feedback