Search code examples
phpwordpressformseloqua

Submit Eloqua form data via POST request on PHP/Wordpress?


My client wants Eloqua forms on their website but we have run into issues with spam. I am embedding the export HTML form the client has exported. The exported form has no protection from spam. I plan to enable reCaptcha on the forms to protect from spam which means sending the form data to the server, then submitting the form data to Eloqua.

Am I able to pass the formData to the server and then send that via a POST request to the form action URL?


Solution

  • I managed to find a solution to this issue. I used jQuery to serialise the form data and send it along with the generated reCaptcha token to the web server. My PHP then checks the token against the reCaptcha API and ensures the score is above 0.8. It then sends the formData via POST to the Eloqua form action URL.

    The check is done server side and the submissions happens on the server side rather than the client side. The form action URL is also removed from the HTML for extra protection.