• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Custom validation script not working

Custom validation script not working 13 years 2 months ago #13014

  • jason0
  • jason0's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hi. I found this article on your forum:

www.rsjoomla.com/customer-support/docume...on-rule.html#content

I copied and edited it a bit, but it doesn't work on our website. Also, does it work for any other field like for example "Username". See the script below:

components/com_rsform/helpers/validation.php
function unique_email($param, $extra=null)
{
if(!RSFormProValidations::email($param,null))
return false;
$formId = JRequest::getInt('formId' );
$db = JFactory::getDBO();
$param = $db->getEscaped($param);
$db->setQuery("SELECT * FROM #__rsform_submission_values WHERE `FieldName`='Email' AND `FieldValue`='".$param."' AND `FormId`='".$formId."'" );;
$db->query();
$invalid = $db->getNumRows();
if ($invalid)
return false;
return true;
}
i added that custom validation to my form's email field because i wanted to make sure that an email address is only used once. it doesn't work because i can use the same email address over and over when submitting.

notice that there's this line that says:
if(!RSFormProValidations::email($param,null))

what's that supposed to check? What do I change it to if I want to validate Username (text field alphanumeric) and make sure that username is only used once (no duplicates).

i'd really appreciate your assistance.
Last Edit: 13 years 2 months ago by jason0.
The administrator has disabled public write access.

Re:Custom validation script not working 13 years 1 month ago #13121

  • jason0
  • jason0's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
82 views and no replies? :ohmy:
The administrator has disabled public write access.

Re:Custom validation script not working 13 years 1 month ago #13384

  • roy2
  • roy2's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
I've got the same problem. RS support said this is workable.

///////
function unique($param, $extra=null)
{
if(!RSFormProValidations::email($param,null))
return false;
$formId = JRequest::getInt('formId' ) ;
$db = JFactory::getDBO();
$param = $db->getEscaped($param);
$db->setQuery("SELECT * FROM #__rsform_submission_values WHERE `FieldName`='Email' AND `FieldValue`='".$param."' AND `FormId`='".$formId."'" ) ;
$db->query();
$invalid = $db->getNumRows();
if ($invalid)
return false;
return true;
}
/////
Code from there : www.rsjoomla.com/customer-support/docume...validation-rule.html

However, I tried many different ways with different servers but still not work. I cannot see the post variable "Email" was passed into the validation.php.

There should be something like :
$Email = JRequest::getVar('Email' ) ;

to get the posted variable "Email" from previous. Very frustrated!
The administrator has disabled public write access.

Re:Custom validation script not working 13 years 1 month ago #13385

  • roy2
  • roy2's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
After 3 days struggle. I did it! Try these :

/////// for Email, use this code ////////
function unique($param, $extra=null)
{
if(!RSFormProValidations::email($param,null))
return false;
$formId = JRequest::getInt('formId' ) ;
$db = JFactory::getDBO();
$param = $db->getEscaped($param);
$db->setQuery("SELECT * FROM #__rsform_submission_values WHERE `FieldValue`='".$param."'" ) ;
$db->query();
$invalid = $db->getNumRows( ) ;
if ($invalid)
return false;
return true;
}

////////////////////////////////////////////////


/////// for something else like.... Name, use this code ////////

function Name($param, $extra=null)
{
if(!RSFormProValidations::alphanumeric($param,null))
return false;
$formId = JRequest::getInt('formId' ) ;
$db = JFactory::getDBO();
$param = $db->getEscaped($param);
$db->setQuery("SELECT * FROM #__rsform_submission_values WHERE `FieldValue`='".$param."'" ) ;
$db->query();
$invalid = $db->getNumRows();
if ($invalid)
return false;
return true;
}

///////////////////////////////

Don't know why RS support keep telling users to use the incorrect code.
They must seriously provide good support to clients. Otherwise...... :angry:
The administrator has disabled public write access.
The following user(s) said Thank You: cuby
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!