Multiple actions on one web form

I need to perform two submit actions on the response of one button click on a web form. One action writes to an internal database and the second action passes to an external system. I can’t have two buttons on the form because an end user would not understand what they do and which one to click on. The problem seems to come from each action completing the submit before the other can run and have access to the form data. I’ve scoured the internet and in general suggestions surround writing javascript code but that does not appear to work and what if a user has javascript shut off. I’ve also tried adding the action onto the button onclick event and the other one on the form action but again one finishes completely and stops the process so the other action never triggers. Any suggestions for accomplishing this is appreciated. Thanks!

I do this all the time, it happens when you process the form, not from the actual click.

How are you trying to go about it?

[php]
if(Communication::InsertMailMsg($_POST)){
$str = “\nSaved to DB:\n[” + $date->format(‘Y-m-d H:i:s’) + "] - " + $body;
$file = fopen(“contact.log”, “a+”);
fwrite($file, $str);
fclose($file);
}

            if (Communication::trigger_email($_POST) && Communication::trigger_email($_POST, true)) {
                $data['code'] = 200;
                $data['msg'] = "Message Sent";
                echo json_encode($data);
            } else {
                $data['code'] = 200;
                $data['msg'] = "Message could not be Sent";
                echo json_encode($data);
            }

[/php]

So, this is a processing of a user contact form. It does a few things,

  1. It inserts the record into a database for record keeping and CRM purposes.
  2. It email the person that sent it, that the message was received by the system.
  3. It emails the person that needs to be notified

All of the notifications are handled through an API call on another system.

Thanks I was able to work around my issue by calling an API code separately and then continuing with the actions of a submit button.

Sponsor our Newsletter | Privacy Policy | Terms of Service