[Solved] Need help with a booking form!

JeLu 02 Jul, 2012
I am working on a booking form and the form is almost done but I have a problem, or rather two.

1. Visitors should only be able to send it in once.

2. Only a limited number of registrations should be possible.

And only registred visitors should be able to sign up.

The last part I managed with autorization action.

I have tried to use Server Side verification for the 1 and 2 but that will not work.

The code I have come up to so far is:
<?php
$user = JFactory::getUser();
$db =& JFactory::getDBO();
$query = "
  SELECT COUNT(*)
    FROM `#__chronoforms_data_formname`
    WHERE `cf_user_id` = '{$user->id}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
 $form->validation_errors[] = "You have already signed up!";
  return false;

}
?>

Perhaps I can´t use Server Side action for this but but with Custom Code I can´t get it to show my form.

JeLu
JeLu 02 Jul, 2012
The first part is solved. My table was named _chronoforms_data_Formname but I used _chronoforms_data_formname in SQL. After changing formname to Formname it works.

JeLu
JeLu 02 Jul, 2012
I have still problem how to count rows and return false if sign up are e.g 50 or greater.

Tried to use mysql_num_rows but that did not work.

Please help.

JeLu
GreyHead 25 Jul, 2012
Hi JeLu,

You can use a MySQL query like this:
<?php
$db =& JFactory::getDBO();
$query = "
    SELECT COUNT(*)
        FROM `#__chronoforms_data_Formname` ;
";
$db->setQuery($query);
$count= $db->loadResult();
if ( $count > 50 ) {
  // take some ation
}
?>

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