jon1009 Posted June 12, 2015 Share Posted June 12, 2015 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 More sharing options...
Barand Posted June 12, 2015 Share Posted June 12, 2015 try if ($_POST['submitted']) { switch ($_POST['submitted']) { case "Send Booking & Pay Deposit": // worldpay stuff //FALLTHRU (no break) case "Send Booking": // email stuff break; } } Link to comment https://forums.phpfreaks.com/topic/296773-run-multiple-actions-on-form-submit/#findComment-1513727 Share on other sites More sharing options...
jon1009 Posted June 14, 2015 Author Share Posted June 14, 2015 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 https://forums.phpfreaks.com/topic/296773-run-multiple-actions-on-form-submit/#findComment-1513858 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.