RSjoomla! - Quality Joomla! Components

My Account






Lost Password?
No account yet? Register

Newsletter Subscribe

If you would like to be one of the first people to hear about the release of our new components then make sure you have subscribed to our announcements list! We won't bug you with unnecessary stuff.




RSform! Logo User Guide
RSform! - Form management component » RSform! Custom scripts and customization examples » Mapping form submission on another external table

Mapping form submission on another external table 

Here's an example of how you could map the submission values of your form to an external database. Note that this example uses an external database.

Let's assume that your form contains the following fields(listed are the field ids):

  • firstname
  • lastname
  • email
  • phone
  • city
  • country
And you want to map them over an external database table.

Edit your form, go to the Scripts tab, and in the Scripts called on form process, type this code:

 //first we make sure that the code is triggered upon submission  

if(isset($_POST['form']['email'])) {
$database2 = $database;
$database2 = new database( 'host', 'user', 'password', 'db', 'prefix(if any)' );//comment this line if you're using the same db where the rsform tables are
$database2->setQuery("INSERT INTO `my_external_table` (`firstname`,`lastname`,`email`,`phone`,`city`,`country`) VALUES ('{$processform['firstname']}', '$processform['lastname']', '$processform['email']', '$processform['phone']', '$processform['city']', '$processform['country']')");
$database2->query();
}