Hi, I'm a newbie using php, chronoforms and chronoconnectivity but I've been able to set up a component for my website for managing registrations and ranking of a competition.
There i encountered two problems i can't solve. I googled a lot but I didn't find an answer to my problems.
1) I'd like chronoconnectivity to add a coloumn on the left side of my table with a progressive rows number.
2) I'd like to add a code in the server side validation of my registration form which doesn't allows users to insert the same data twice.
eg. If data inserted in the form fields: name , surname and date_of_birth are already inserted in the same row of the database return 'Data already exist!'.
I don't know much of php and I hope someone could help me with a step by step explanation.
Thanks in advance!
[[>> Greyhead : I've copied this post over to the ChronoConnectivity Forum and will answer the CC part there. <<]]
There i encountered two problems i can't solve. I googled a lot but I didn't find an answer to my problems.
1) I'd like chronoconnectivity to add a coloumn on the left side of my table with a progressive rows number.
2) I'd like to add a code in the server side validation of my registration form which doesn't allows users to insert the same data twice.
eg. If data inserted in the form fields: name , surname and date_of_birth are already inserted in the same row of the database return 'Data already exist!'.
I don't know much of php and I hope someone could help me with a step by step explanation.
Thanks in advance!
[[>> Greyhead : I've copied this post over to the ChronoConnectivity Forum and will answer the CC part there. <<]]
Hi federico85,
Please try this:
Bob
Please try this:
$db =& JFactory::getDBO();
$name = JRequest::getString('name', '', 'post');
$surname = JRequest::getString('surname', '', 'post');
$date_of_birth = JRequest::getString('date_of_birth', '', 'post');
$query = "
SELECT COUNT(*)
FROM `#__some_table`
WHERE `name` = '$name'
AND `surname` = '$surname'
AND `date_of_birth` = '$date_of_birth';
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
return "This entry is already registered";
}
Note: You need to replace some_table with the name of your table.Bob
Hi Bob!
Thanks for your advice regarding the rows number column... It works perfectly!
Now I don't know why the code you sent me for the server side validation doesn't work.
I copied and pasted it in the server side validation box and I replaced it as follows (with the right name of the table):
Thanks for your advice regarding the rows number column... It works perfectly!
Now I don't know why the code you sent me for the server side validation doesn't work.
I copied and pasted it in the server side validation box and I replaced it as follows (with the right name of the table):
$db =& JFactory::getDBO();
$name = JRequest::getString('name', '', 'post');
$surname = JRequest::getString('surname', '', 'post');
$date_of_birth = JRequest::getString('date_of_birth', '', 'post');
$query = "
SELECT COUNT(*)
FROM `#__iscrizioni_olimpiadi`
WHERE `name` = '$name'
AND `surname` = '$surname'
AND `date_of_birth` = '$date_of_birth';
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
return "This entry is already registered";
}
Hi Bob!
Now i made it work... I was wrong replacing the name of the table.
Instead of writing #__jos_chronoforms_my_table I had to write #__chronoforms_my_table and now it works perfectly!
Thank you again...
Now i made it work... I was wrong replacing the name of the table.
Instead of writing #__jos_chronoforms_my_table I had to write #__chronoforms_my_table and now it works perfectly!
Thank you again...
Hi federico85,
Please try this:
$db =& JFactory::getDBO();
$name = JRequest::getString('name', '', 'post');
$surname = JRequest::getString('surname', '', 'post');
$date_of_birth = JRequest::getString('date_of_birth', '', 'post');
$query = "
SELECT COUNT(*)
FROM `#__some_table`
WHERE `name` = '$name'
AND `surname` = '$surname'
AND `date_of_birth` = '$date_of_birth';
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
return "This entry is already registered";
}
Note: You need to replace some_table with the name of your table.Bob
Hi Bob,
I wonder where should I put this code inside chronoconnectivity 🤨
Hi s_meliana,
This was really a ChronoForms question and the code was for CFv3 where it goes in the ServerSidea validation box on the Anti-spam tab.
In ChronoForms v4 you could use a modified version of this code in a Custom ServerSide Validation action near the beginning of the On Submit action.
Bob
This was really a ChronoForms question and the code was for CFv3 where it goes in the ServerSidea validation box on the Anti-spam tab.
In ChronoForms v4 you could use a modified version of this code in a Custom ServerSide Validation action near the beginning of the On Submit action.
Bob
This topic is locked and no more replies can be posted.