Hi!
I have a validation on serverside for at field where i store Social Security number. I need this so only one record with the same number is stored.
I use:
Sorry for a but swedish here but it is only in the error message. This number is stored like yymmdd-nnnn and the validation works for the six first number but after '-' it does not check at all.
Is there a way to solve this problem or do I have to store only numbers? (I have about 5500 records that nedds to be edited in that case.
Thanks in advance.
I have a validation on serverside for at field where i store Social Security number. I need this so only one record with the same number is stored.
I use:
<?php
$result = JRequest::getInt('nnnn', '', 'post');
if ( !$result) {
return "You must enter a reference number";
}
$db =& JFactory::getDBO();
$query = "
SELECT count(*)
FROM `#__MyTable`
WHERE `nnnn` = $result;
";
$db->setQuery($query);
$in_use = $db->loadResult();
if ( $in_use) {
return "Personnumret används redan använd Ändra Elevfil istället om det är din elev. I annat fall tar du kontakt med Company på mail[at]example.com";
}
?>
Sorry for a but swedish here but it is only in the error message. This number is stored like yymmdd-nnnn and the validation works for the six first number but after '-' it does not check at all.
Is there a way to solve this problem or do I have to store only numbers? (I have about 5500 records that nedds to be edited in that case.
Thanks in advance.
Hi JeLu ,
Just checking my understanding. The result submitted from the form is 1234 and the value in the database is - for example 801011-1234?
Bob
Just checking my understanding. The result submitted from the form is 1234 and the value in the database is - for example 801011-1234?
Bob
Hi!
Thank you for a such a quick answer. I have used past weekend to reed your fantastic book ChronoForms 1.3 and have some idees that does not work.
No in the form I have users to fill in the full number eg. 801010-1234 and when my server validation check if this number exist it checks only the 6 first digits so 801010-5678 is handeled as 801010-1234 and gives an error.
By the way, is there a similar book for connectivity?
Regards
Jerker
Thank you for a such a quick answer. I have used past weekend to reed your fantastic book ChronoForms 1.3 and have some idees that does not work.
No in the form I have users to fill in the full number eg. 801010-1234 and when my server validation check if this number exist it checks only the 6 first digits so 801010-5678 is handeled as 801010-1234 and gives an error.
By the way, is there a similar book for connectivity?
Regards
Jerker
Hi Jerker,
Ok, then I think you need to (a) specify the input as a string (getInt() speifies an integer)
Glad you enjoyed The ChronoForms Book :-)
There isn't a ChronoConenctivity Book but I am writing a series of How-To Documents for ChronoConnectivity that you can downlad here (for free at the moment).
Bob
Ok, then I think you need to (a) specify the input as a string (getInt() speifies an integer)
$result = JRequest::getString('nnnn', '', 'post');
and (b) add quotes round the resultWHERE `nnnn` = ".$db->quote($result).";
Glad you enjoyed The ChronoForms Book :-)
There isn't a ChronoConenctivity Book but I am writing a series of How-To Documents for ChronoConnectivity that you can downlad here (for free at the moment).
Bob
This topic is locked and no more replies can be posted.