• 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: Generator of random numbers to form

Generator of random numbers to form 9 years 11 months ago #27403

Hello,

I need help with the script generator of random numbers to form.

I need to identify it as payment for the invoice.

conditions:
The generator must generate only numbers
number must always be seven positions (xxxxxxx)
number can not be repeated - should be stored externally.

____

I know that I need to create a hidden field in the form. But I dont know where I then insert this script.

Can you help me?
The administrator has disabled public write access.

Generator of random numbers to form 9 years 11 months ago #27429

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
As you have said, you need to add a hidden field to the form. Head to Components >> RSForm!Pro >> Manage Forms >> edit your form >> Components >> add a Hidden Field form component to your form. You can read more about this type of field here:

www.rsjoomla.com/support/documentation/v...37-hidden-field.html

Now, head to Components >> RSForm!Pro >> Manage Forms >> edit your form >> Properties >> PHP Scripts and add the following code:
function random(){
$x=rand(1000000,9999999);
$formID=$_POST['form']['formId'];
$db = JFactory::getDbo();
$query = $db->setQuery("SELECT `SubmissionId` FROM #__rsform_submission_values WHERE `FormId`='$formID' AND `FieldName`='random' AND `FieldValue`='$x' LIMIT 1");
$results = $db->loadResult();
if (!$results) {return $x;}
else random();
}
$_POST['form']['hidden_field']=random();

in the "Script called on form process" area.

Remember to replace "hidden_field" with your hidden field's actual name.
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 9 years 11 months ago by silviup.
The administrator has disabled public write access.
  • 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!