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']')");

4 persons found this article helpful.

Was this article helpful?

Yes No
Sorry about that