Hello! i've got a problem with server side validation:
Here is the code i put on the ssv box:
The problem is that it doesn't work..😟 i get this error anyway, is there anyone who can help?
Thank you so much
Here is the code i put on the ssv box:
<?php
$cf = JRequest::getString('codicefiscale', '', 'post');
$db =& JFactory::getDBO();
$sql = "
SELECT COUNT(*)
FROM `jos_chronoforms_form_iscritti`
WHERE `codicefiscale` = ".$db->Quote($cf);
";
$db->setQuery($sql);
$result = $db->loadResult();
if ( !$result ) {
return "This user is already in the database ";
}
?>
The problem is that it doesn't work..😟 i get this error anyway, is there anyone who can help?
Thank you so much
Hi bubila,
What error do you get?
I think that his line
Bob
What error do you get?
I think that his line
if ( !$result ) {
should be if ( $result ) {
Bob
Hello Bob,
I think you're right! i was in such a hurry that i didn't saw this error...
:)
Sorry but i'm not that expert in php...
THANK YOU SO MUCH
I think you're right! i was in such a hurry that i didn't saw this error...
:)
Sorry but i'm not that expert in php...
THANK YOU SO MUCH
i'm back again.. the validation used to work correctly, but today while testing other functionalities, i've tryied again with this one and it doesn't work anymore. Any suggestion?
Thank you so much
Elisa
Thank you so much
Elisa
Hi Elisa,
Something must have changed if it's stopped working :-(
Impossible to say what from here though.
Bob
Something must have changed if it's stopped working :-(
Impossible to say what from here though.
Bob
I've added a filed in the table of the db, but left the code as it was, now i'm trying to add another field in the validation code:
the name of the table hasn't changed and neither the field i'm cheking.
did i mess up again with the code?
<?php
$cf = JRequest::getString('codicefiscale', '', 'post');
$cat = JRequest::getString('categoria', '', 'post');
$db =& JFactory::getDBO();
$sql = "
SELECT COUNT(*)
FROM `jos_chronoforms_form_iscritti`
WHERE `codicefiscale` = '".$db->Quote($cf);"'
AND 'categoria' = '".$db->Quote($cat);"';
";
$db->setQuery($sql);
$result = $db->loadResult();
if ( $result ) {
return "Puoi iscriverti una sola volta per ogni categoria";
}
?>
but still no success..the name of the table hasn't changed and neither the field i'm cheking.
did i mess up again with the code?
I've cheked your book (form validation and security) and i've update my code as follows:
and now it works perfectly!
thank you so much!
Elisa
<?php
$db =& JFactory::getDBO();
$cf = JRequest::getString('codicefiscale', '', 'post');
$cat = JRequest::getString('categoria', '', 'post');
$query = "
SELECT COUNT(*)
FROM `#__chronoforms_form_iscritti`
WHERE `codicefiscale` = '$cf' AND `categoria` = '$cat' ;
";
$db->setQuery($query);
if ( $db->loadResult() ) {
return "Sei già iscritto al concorso";
}
?>
and now it works perfectly!
thank you so much!
Elisa
Hi bubila,
Glad you got it working, well done.
I think perhaps that $db->Quote($xxx) needs to be $db->quote($xxx) (with q instead of Q).
Bob
Glad you got it working, well done.
I think perhaps that $db->Quote($xxx) needs to be $db->quote($xxx) (with q instead of Q).
Bob
Hi friends
I'm study Chronoforms from this forum and I have one question: Where is the ssv box? Where I have to write this code?
I need to create a application and I'll try chronoforms. I need to create a login system with validation, and if the user is valid I need to get one field from the table.
Any help will be appreciated
Thank you
I'm study Chronoforms from this forum and I have one question: Where is the ssv box? Where I have to write this code?
I need to create a application and I'll try chronoforms. I need to create a login system with validation, and if the user is valid I need to get one field from the table.
Any help will be appreciated
Thank you
This topic is locked and no more replies can be posted.