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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.