• 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: php code on submission

php code on submission 15 years 3 months ago #6200

Is it possible to have RSForm!Pro execute the \"on form process\" PHP code after it's added the form data to the database via the mappings plugin?

I need to get an AUTO_INCREMENT ID from the database and then add another record to a 2nd table. Using the mysql_insert_id() function doesn't work, and if I do a SELECT to get the most recent one, it returns the one previous to the one that the form ultimately creates (indicating that it's executing that code before it populates the database).

If I can't do that, then it looks like I'll have to run a cron job every minute or three to check for new entries, which is rather ugly (and unreliable, should more than one person submit the form within that time, which is [thankfully] extremely unlikely in this case).

TIA
The administrator has disabled public write access.

Re:php code on submission 15 years 3 months ago #6402

I'm no expert but, I had a similar situation that I resolved by calling a //code in a hidden field in the form to generate the new line in one table using the time() as an identifiable but unique string for the name, then (in the same code) did a query to retrieve that new record's automatically generated ID.

Then I did an 'update' on that record using the 'Script called on form process' after I'd gotten the input from the form.

Its probably pretty obvious but, here's my code:
//<code>
$curTime=time();
$addUser=mysql_query("INSERT INTO jos_user (name) VALUES ('$curTime')");
if($addUser){
$rez = mysql_query("SELECT id FROM jos_user WHERE name='$curTime'");
while($r = mysql_fetch_assoc($rez))
          $id = $r['id'];
return $id;
} else {
return "Failed";
}
//</code>

Hope it helps.
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!