Buy Now
Sign in

Check if email address already exist

Joomla-Newbies , September 04 2011
J
Joomla-Newbies
Hi all,

I need some help, I have created a customer registration form, the form is working perfectly can send capture data to emails and can save to the database too. However to prevent existing customers from registerring twice I need to check if their email already exist. I am stuck please help.

Thank you fo your help. As a side note,my form does not have a username field, it is purely for registration purpose only, not for customers to login.
GreyHead
Hi Joomla-Newbies ,

You can either add a few lines in the ServerSide validation to check the table; or you could use Ajax to run the check from the browser. The main code for the Server Side validation approach is like this:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__some_table`
WHERE `email` = '{$form->data['email']}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
$form->validation_errors['email'] = "Email is already registered.";
return false;
}
?>


Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
D
Dinosrules
Hi,

I am trying to check if an email field is already in the database in my chrono form. I am using a custom server side validation on "on submit" event right after the ReCaptcha validation. However it's not working.

I have replaced the "#__some_table" with my table name and I left the rest untouched because my email field it is called "email".

Am I doing something wrong? Maybe I'm missing something.
Any help would be greatly appreciated.

Thank you!
GreyHead
Hi Dinosrules,

Have you dragged an Event Loop action to the OnFail event of the Server Side Validation action?

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
D
Dinosrules
Yes I did that and in fact the form is not stopping. It registers all the data into the db and shows the success message. All my email events and db save actions are placed after the server side validation, so it should stop.

Any other ideas?
GreyHead
Hi Dinosrules,

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
D
Dinosrules
Hi Bob,

Thank you for your time. My form is attached.
Attachments
CFV4_FormsBackup_ON_10_Oct_2011_22_40_31.zip
(14.53 KiB)
539 Downloads/Views
D
Dinosrules
Hi Bob,

Any updates on this?
S
Sciadini
Hi,
I had the same problem and I almost solved, that is I insert the code in email field in Auto Server Side Validation and I insert the Event Loop in On Fail of Auto Server Side Validation, the error message is displayed, but the data is the same as recorded in the database... how can I not save the data?

Thank's
S
Sciadini
I Resolved thank's

I moved the Joomla User Registration and the Auto Server Side Validation on DB Save. Order it's important and that both are above DB Save.