Forums

check if already subscribed

SPABO 14 Apr, 2017
Hi
I want to check is somebody already subscribed, the form then should give a message, Sorry, you already subscribed and the form should be "stopped"

I added a new event in the Eventswitcher, called "ingeschreven"
In this event I added a Systemmessage and a Stopper

In the PHP field I put this code
$datum = JRequest::getString('Datum', '', 'post');
$user_info = JRequest::getString('email', '', 'post');
if ( $datum && $user_info ) {
  $db =& JFactory::getDBO();
  $query = "
    SELECT COUNT(*)
      FROM `nestv_chronoengine_chronoforms_data_basic`
      WHERE `Datum` = '{$datum}'
        AND `email` = '{$user_info}';
  ";
  $db->setQuery($query);
  $count = $db->loadResult();
  if ( $count > 0 ) {
  return "ingeschreven";
  }


But the form does not stop, and no systemmessage

Note: I check on "Datum" and "email"
Both fields are in the form en DB table

Where am I going wrong?
Max_admin 14 Apr, 2017
Hi Kees,

And where do you have this code ? did you test that it returns the correct value in this case ? please try to "echo" that event name, does it display correctly when the user is subscribed ?

You can also use a "Data read" function, and call your functions in the "found" event, the conditions can be like this:

Model.Datum:{data:Datum}
Model.email:{data:email}

In this case you don't need the code above or the event switcher.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
SPABO 14 Apr, 2017
The code is in a PHP section (from "LOGIC")
This code worked fine in V4

Read Data does not work as you proposed
Max_admin 14 Apr, 2017
Hi Kees,

Why "Read data" does not work as proposed ?

Can you post a screenshot of your "Events" section at the moment ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
SPABO 14 Apr, 2017
Error message when Data Read implemented

#1054 Unknown column 'Model.Datum' in 'where clause' SQL=SELECT COUNT(`Data46`.`aid`) AS `Data46.count` FROM `#__chronoengine_chronoforms_data_basic` AS `Data46` WHERE `Model`.`Datum` = '13-05-2017' AND `Model`.`email` = 'xxxxx@xxxxx.nl';

Max_admin 14 Apr, 2017
Answer
Hi Kees,

Yes, the "Model" in this case should be "Data46", its written at the top of the function config.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
SPABO 15 Apr, 2017
Hi Max,

It works now, my learning curve will improve in the end 😀

Rgds

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