On the server side validation I would like to "check"the age of the subscriber, his/het age should be 14 years as from 2012-01-01 (yyyy-mm-dd)
Tablename : J25_chronoforms_data_MP_2
Birthday : cb_geboren
I tried this
Tablename : J25_chronoforms_data_MP_2
Birthday : cb_geboren
I tried this
<?php
$geboren = JRequest::getString('cb_geboren', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `J25_chronoforms_data_MP_2`,
WHERE `cb_lidcode` = '{$geboren}';
$db->setQuery($query);
if ($geboren > 1949-01-01){
$form->validation_errors[''] =
"Too old";
return false;}
?>
However, this gives errors..:(
Hi SPABO,
It looks as though the quote to end the query and the line to execute the query $xxx = $db->getResult(); are missing - but I can't see that the query does anything at all??
You also can't usefully compare dates as strings (and the quotes are missing round the 1949 date too).
Bob
It looks as though the quote to end the query and the line to execute the query $xxx = $db->getResult(); are missing - but I can't see that the query does anything at all??
You also can't usefully compare dates as strings (and the quotes are missing round the 1949 date too).
<?php
$geboren = $form->data['cb_geboren'];
/*
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__chronoforms_data_MP_2`,
WHERE `cb_lidcode` = '{$geboren}';
"; // add this line
$db->setQuery($query);
$db->getResult(); // add this line
*/
if ( strtotime($geboren) > strtotime('1949-01-01') ) {
$form->validation_errors['cb_geboren'] = "Too old";
return false;
}
?>
Bob
Dear Bob,
I'm a fan of Chronforms, however I'm lacking PHP skills.
I now have this code in (to define TOO YOUNG)
Tx again !!
I'm a fan of Chronforms, however I'm lacking PHP skills.
I now have this code in (to define TOO YOUNG)
Tx again !!
<?php
$geboren = $form->data['cb_geboren'];
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `J25_chronoforms_data_CK MATCHPLAY_2`,
WHERE `cb_lidcode` = '{$geboren}';
";
$db->setQuery($query);
$db->getResult();
if ( strtotime('1949-01-01')< strtotime($geboren) ) {
$form->validation_errors['cb_geboren'] = "Sorry, maar je bent te jong om aan deze wedstrijd deel te nemen.";
return false;
}
?>
Hi SPABO,
What exactly is the problem?
The code looks OK - except that the DB query still does nothing.
Bob
What exactly is the problem?
The code looks OK - except that the DB query still does nothing.
Bob
Hi Bob,
What I tried to say the code as below does work nicely
But now I'm puzzled..
Pls advise
Rgds
Kees
What I tried to say the code as below does work nicely
But now I'm puzzled..
except that the DB query still does nothing
Pls advise
Rgds
Kees
Hi Kees,
Not much to say, the output from the query isn't assigned to a variable and isn't used anywhere. This code would do the same:
Bob
Not much to say, the output from the query isn't assigned to a variable and isn't used anywhere. This code would do the same:
<?php
if ( strtotime('1949-01-01') < strtotime($form->data['cb_geboren']) ) {
$form->validation_errors['cb_geboren'] = "Sorry, maar je bent te jong om aan deze wedstrijd deel te nemen.";
return false;
}
?>
Bob
This topic is locked and no more replies can be posted.