Advertisement
BaneD

Webhook: Unable to Fetch POST Data from Form Fields

Jan 7th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2. /* From forum post: */
  3. $customerPhone = implode('', $obj["q281_primaryPhone"]);
  4.  
  5. $customerName = implode('', $obj['q241_fullName']);
  6.  
  7. $token = "?token=V5E6dEyuv4nw3HFD98fUF6N8rQWhX3";
  8.  
  9. $parameters = $token . "&name=" . $customerName . "&phone=" . $customerPhone . "&size=1";
  10.  
  11. $emailfrom = "admin@*****.com"; //Sender, replace with your email
  12. $emailto = "jesse@****.com"; //Recipient, replace with receivers email
  13. $subject = "JotForm Test Webhook"; //Email Subject
  14.  
  15. //Send email
  16.  
  17. mail($emailto, $subject, $parameters, "From: <$emailfrom>");
  18.  
  19. //---------------------------------------------------------------------------------------------
  20. /* --- what should be placed --- - if you want to get the email */
  21.  
  22. $result = $_REQUEST['rawRequest'];
  23.  
  24. $result = stripslashes($result);
  25. $obj = json_decode($result, true);
  26.  
  27. $emailfrom = "admin@*****.com"; //Sender, replace with your email
  28. $emailto = "jesse@****.com"; //Recipient, replace with receivers email
  29. $subject = "JotForm Test Webhook"; //Email Subject
  30.  
  31. //Prepare email body text, you can change anything from here
  32.  
  33. $body = "Contact Form Submissions"; //Title
  34. $body .= "n";  //Nothing but new line
  35. $body .= "Name: ". implode(' ', $obj['q247_fullName247']); // to change full name array to string
  36. $body .= "n";  //Nothing but new line
  37. $body .= "n";
  38. $body .= "Email: ". $obj['q250_emailAddress']; //Replace with your Email field name
  39. $body .= "n";
  40. $body .= "Reason for Visit: ". $obj['q277_reasonFor'];
  41. $body .= "n";
  42. $body .= "Submissions ID: ". $_POST['submissionID']; //If you'd like to catch submissionsID
  43.  
  44. //Send email
  45. mail($emailto, $subject, $body, "From: <$emailfrom>");
  46.  
  47. //------------------------------------------------------------------
  48. // Now if you want to have the submitted data prepared as some form of parameters then you should modify the code to something like this:
  49. $result = $_REQUEST['rawRequest'];
  50.  
  51. $result = stripslashes($result);
  52. $obj = json_decode($result, true);
  53.  
  54. //We can only now use the $obj variable, in your script (all the way at the top), we did not have it declared..
  55. $customerPhone = implode('', $obj["q281_primaryPhone"]);
  56. $customerName = implode('', $obj['q241_fullName']);
  57.  
  58. $token = "?token=V5E6dEyuv4nw3HFD98fUF6N8rQWhX3";
  59.  
  60. $parameters = $token . "&name=" . $customerName . "&phone=" . $customerPhone . "&size=1";
  61.  
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement