check if e-mail exists in database and if so return system message

Li Liesbeth 11 Mar, 2018
Hi,
​
I need som help with this,
​
I created a form which you can find here. Form fields are added to database and all works fine.
​
Now the idea is that people can sent a form just 1 time per e-mailaddres, Therefore I want the form to check on submission wether an e-mailaddress already exists in the database or not. If so, a system-message like : 'e-mail already exists' has to be returned.
If the e-mail does not exists formsubmission can be completed .
​
This is what I have tried:
​
- adding a db read action on submit , but I am not sure what to fill in there. (model name, php code in where conditions, etc)
- I added a message action and evend loader in the found field of db read action
- I added emailaction, database save action, redirect etc in the not found field of db read action.
Now the message 'e-mail already exests' is always returned (wether it already exists in database or not) and fields are not saved to database.
​
Would be great to get some help on how to get achieve this.
​
Kind regards,
Liesbeth
Gr GreyHead 12 Mar, 2018
Hi Liesbeth,
​
Please see page 20 of the CFv6 manual for the DB Read settings.
​
While you can use the Found and Not Found of the DB Read action boxes you might get better control using an Event Switcher action after the DB Read.
​
Adding a Debugger action will help you see exactly what is happening - in this case I suspect that your DB Read settings are incorrect and no record is being found.
​
Bob
Li Liesbeth 12 Mar, 2018
Thanks,
​
I added an Event Switcher after de DB Read and addeda debugger. (I read you manual this weekend, also about event switching)
​
I think indeed that de DB Read settings are incorrect. What do I need to fill in there to check if an email allready exests?
​
Here's the debug info:
​
Array
(
[chronoform] => stimformulier
[event] => submit
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 1
[weromwinne] => wyt ik niet
[checkbox] => 1
[g-recaptcha-response] => 03ANcjosp8MjO3QgDacPX2BOX7aEzalxLf73aDeStpYnK_RRhcK3PsPlBEdtqycRl7btVxgjFNoQ1QeGvZh8yue_IfM2w6QhWFzB9FgfsfbrjT6hBxpTJLoaLXXq586DiYl4oWQPbJqhZ2h_s5byOtvZcvy9uB5_6IvQou-d7tMXhVZVhNVOk2FugUxaWb67ICHimfO8QCmE9wMw-GDjY1h3XNMx-FafKqD32Ab5WYlK7Z-SJezsWT08URxqmh5Flvg_sw7mUSr6el4gJ2iUFXEAK9YoTVHU4CobVicWMP8wVlf3gokV2NsUOy-Esebd0zU4S1Km_9vDmRwtXqCx5gqilkan9mXpU7sivq9WAap9yvry2jnDYChJJi9dAZE2gDvGqDioc8XVWR96-23V89R585HucLSRiK7TIC6xLCDYmg6nl575uprpUJZyJdcJNLdPo_MsD547D5Z74lxQgB429RsqoAwS-Ipg
[fersjtoere] =>
[_ga] => GA1.2.1477110897.1515147185
[intercom-id-tvfkokak] => 2be8c48b-a1e9-440e-8c4d-1566f028c1b2
[__atuvc] => 13|3
[_gid] => GA1.2.610775579.1520793107
[48cc7a9adeeae7274f311b82a3444ae2] => irknlo2jo9vvl7u0ikb7f85ui2
[b933176a7c79149ffad07412ce33ffdd] => savbe0ebdg86pq4ph70g27jek2
[Itemid] => 126
[option] => com_content
[view] => article
[id] => 9
[stimformulier] =>
)
Array
(
[google_nocaptcha3] => Array
(
[response] => Array
(
[success] => 1
[challenge_ts] => 2018-03-12T11:28:54Z
[hostname] => www.fryskereklamepriis.nl
)

[_success] => De NoCaptcha verificatie was geslaagd.
[var] => 1
)

[validate_fields2] => Array
(
[log] => Automatic validation enabled.
[var] => 1
)

[read_data12] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`emailadres`.`aid`) AS `emailadres.count` FROM `rteks_chronoforms_data_stimformulier` AS `emailadres`;
[1] => SELECT `emailadres`.`aid` AS `emailadres.aid`, `emailadres`.`user_id` AS `emailadres.user_id`, `emailadres`.`created` AS `emailadres.created`, `emailadres`.`modified` AS `emailadres.modified`, `emailadres`.`namme` AS `emailadres.namme`, `emailadres`.`emailadres` AS `emailadres.emailadres`, `emailadres`.`fideokar` AS `emailadres.fideokar`, `emailadres`.`weromwinne` AS `emailadres.weromwinne` FROM `rteks_chronoforms_data_stimformulier` AS `emailadres` LIMIT 30;
)

[var] => Array
(
[0] => Array
(
[emailadres] => Array
(
[aid] => 1
[user_id] => 808
[created] => 2018-03-11 16:36:10
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 1
[weromwinne] => wyt ik net
)

)

[1] => Array
(
[emailadres] => Array
(
[aid] => 2
[user_id] => 808
[created] => 2018-03-11 16:45:23
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 1
[weromwinne] => wyt ik net
)

)

[2] => Array
(
[emailadres] => Array
(
[aid] => 3
[user_id] => 808
[created] => 2018-03-11 16:50:00
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 1
[weromwinne] => wyt ik net
)

)

[3] => Array
(
[emailadres] => Array
(
[aid] => 4
[user_id] => 808
[created] => 2018-03-11 16:51:38
[namme] => Liesbeth
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 2
[weromwinne] => wyt ik net
)

)

[4] => Array
(
[emailadres] => Array
(
[aid] => 5
[user_id] => 808
[created] => 2018-03-11 16:57:28
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 3
[weromwinne] => wyt ik niet
)

)

[5] => Array
(
[emailadres] => Array
(
[aid] => 6
[user_id] => 0
[created] => 2018-03-12 11:27:07
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 1
[weromwinne] => wyt ik niet
)

)

)

)

[save_data20] => Array
(
[data] => Array
(
[created] => 2018-03-12 11:29:03
[user_id] => 0
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 1
[weromwinne] => wyt ik niet
)

[_success] => Gegevens met succes opgeslagen
[log] => Array
(
[0] => INSERT INTO `rteks_chronoforms_data_stimformulier` (`created`, `user_id`, `namme`, `emailadres`, `fideokar`, `weromwinne`) values ('2018-03-12 11:29:03', '0', 'Liesbeth Hiddema', 'liesbethhiddema@hotmail.com', '1', 'wyt ik niet');
)

[var] => Array
(
[created] => 2018-03-12 11:29:03
[user_id] => 0
[namme] => Liesbeth Hiddema
[emailadres] => liesbethhiddema@hotmail.com
[fideokar] => 1
[weromwinne] => wyt ik niet
[aid] => 7
)

)

[email9] => Array
(
[recipients] => Array
(
[0] => liesbethhiddema@hotmail.com
)

[subject] => dyn stim op telvysjereklame
[body] => Bêste Liesbeth Hiddema

Tige tank foar dyn stim op de Fryske Televysjereklame.
<table width="100%" cellpadding="5" cellspacing="3" border="0" class="ui table"><tr><td width="30%" valign="top" align="right"><strong>Namme:</strong></td><td width="70%" valign="top" align="left">Liesbeth Hiddema</td></tr><tr><td width="30%" valign="top" align="right"><strong>E-mailadres:</strong></td><td width="70%" valign="top" align="left">liesbethhiddema@hotmail.com</td></tr><tr><td width="30%" valign="top" align="right"><strong></strong></td><td width="70%" valign="top" align="left">Fideo 1</td></tr><tr><td width="30%" valign="top" align="right"><strong>Jou oan werom't dizze telefyzjekommersjal neffens dy winne moat.</strong></td><td width="70%" valign="top" align="left">wyt ik niet</td></tr></table>
[reply_name] => Fryske reklamepriis
[reply_email] => info@skelp.org
[result] => de Email is met succes verstuurd.
[var] => 1
)

[email21] => Array
(
[recipients] => Array
(
[0] => info@skelp.org
)

[subject] => ynstjoering stim televysjereklame
[body] =>
<table width="100%" cellpadding="5" cellspacing="3" border="0" class="ui table"><tr><td width="30%" valign="top" align="right"><strong>Namme:</strong></td><td width="70%" valign="top" align="left">Liesbeth Hiddema</td></tr><tr><td width="30%" valign="top" align="right"><strong>E-mailadres:</strong></td><td width="70%" valign="top" align="left">liesbethhiddema@hotmail.com</td></tr><tr><td width="30%" valign="top" align="right"><strong></strong></td><td width="70%" valign="top" align="left">Fideo 1</td></tr><tr><td width="30%" valign="top" align="right"><strong>Jou oan werom't dizze telefyzjekommersjal neffens dy winne moat.</strong></td><td width="70%" valign="top" align="left">wyt ik niet</td></tr></table>
[reply_name] => Fryske Reklamepriis
[reply_email] => info@skelp.org
[result] => de Email is met succes verstuurd.
[var] => 1
)

)
Gr GreyHead 12 Mar, 2018
Hi liesbeth,
​
You only need the first query - SELECT COUNT but it needs to have a Condition added to check the value of the email address. Please check the manual for the way to do that.
​
Bob
Li Liesbeth 12 Mar, 2018
Thank you, I slected 'first matching record' at data settings.
​
The field id of the emailadres is; emailadres and this is also the name of the column of the emailadresses in the database.
Based on the manuel I added this sentence in the field where conditions
​
emailadres:{data:emailadres}
​
is that the right way?
Gr GreyHead 12 Mar, 2018
Hi Liesbeth,
​
That looks OK to me. I would probably check a record count but either will work.
​
Bob
This topic is locked and no more replies can be posted.