Jump to content

Run Multiple Actions on Form Submit


jon1009

Recommended Posts

Hello All,

 

I have created a form that has 2 buttons. Button 1 sends the content of the form via email Button 2 Redirects to WorldPay's Payment page. Which works great however I would like to send the contact of the form via email aswell if Button 2 is clicked. This needs to be done before the redirect kicks in. I've tried all sorts but not had any luck. snippets of my code below 

 

Button 1 PHP

        if ($_POST['submitted']) {
          $sent = wp_mail($to, $subject, $message, $headers);
          if($sent) my_contact_form_generate_response("success", $message_sent); //message sent!
          else my_contact_form_generate_response("error", $message_unsent);} //message wasn't sent
         else //no submitted button
        {

HTML Button Code 

             <input class="btn" type="submit" name="SUBMIT" value="Send Booking & Pay Deposit" onclick="bookingform.action='https://secure-test.worldpay.com/wcc/purchase';return true;">
             <input class="btn" type="submit" name="submitted" value="Send Booking">

Cheers

 

Jon

Link to comment
https://forums.phpfreaks.com/topic/296773-run-multiple-actions-on-form-submit/
Share on other sites

 

try

if ($_POST['submitted']) {
    switch ($_POST['submitted']) {
        case "Send Booking & Pay Deposit":

                // worldpay stuff

                //FALLTHRU (no break)
        case "Send Booking":

                // email stuff

                break;
    }
}

 

Hello Barand,

 

Thanks for the reply. The only code I have from WorldPay is this link/ form action "https://secure-test.worldpay.com/wcc/purchase';return true;" and some hidden fields relating to the shop id. Ive tried putting that in the first case but couldn't get that to work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.