I have an RSForm which has the following fields:

  • Full Name
  • Email Address

I only want to capture new data, how can I use the $_POST script to check if the email address submitted is already in the database?

According to the RSForms documentation I can do this using


but I'm not really sure what code to use.

  • I believe you will need to create a function and database query to pull the email addresses from the database and match them against the one submitted from your form. The code you provided in your question will only display the email address submitted
    – Lodder
    Jan 20, 2015 at 16:57

1 Answer 1


You need to enter the following into the 2nd textarea in the form properties tab under "PHP Scripts":

$formId = 0; // CHANGE THIS VALUE to your form ID

$db = JFactory::getDbo();
$query = $db->getQuery();

    ->where("FormId = " . $db->q($formId))
    ->where("FieldValue = " . $db->q($_POST['form']['email_address'] ));


$num_rows = $db->getNumRows();

// We found this email in the submissions
if ($num_rows > 0) {
    $invalid[] = RSresolveComponentName('email_address', $formId);
    echo RSshowForm($formId, $_POST['form'], $invalid);

You could also create a new validation rule by adding this function to this file: components/com_rsform/controller/validation.php, which can be selected by editing the email_address field and selecting "unique" as the Validation Rule.

function unique($param, $extra=null)
    $db = JFactory::getDBO();
    $param = $db->getEscaped($param);
    $db->setQuery("SELECT * FROM #__rsform_submission_values WHERE `FieldName`='email_address' AND `FieldValue`='".$param."'");
    $invalid = $db->getNumRows();

    if ($invalid)
        return false;

    return true;

There is a little more documentation on custom validations on this page. https://www.rsjoomla.com/support/documentation/rsform-pro/customizing-rsform-pro/custom-validation-rules.html

This thread might also prove helpful: https://www.rsjoomla.com/forum/37-rsform-pro/9162-setup-form-so-each-user-can-only-submit-once-.html

  • @Rusty is this answer "acceptable"?
    – mickmackusa
    Feb 2, 2019 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.