Guest User

Untitled

a guest
Jun 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. custom_my_form($form, &$form_state) {
  2. $form['user_firstname'] = array(
  3. '#type' => 'textfield',
  4. '#title' => 'ID',
  5. );
  6. $form['user_email'] = array(
  7. '#type' => 'textfield',
  8. '#title' => 'Email',
  9. );
  10. $form['user_pwd'] = array(
  11. '#type' => 'password_confirm',
  12. '#required' => TRUE,
  13. );
  14. $form['submit_button'] = array(
  15. '#type' => 'submit',
  16. '#value' => 'Submit',
  17. );
  18. return $form;
  19. }
  20.  
  21. function custom_my_form_submit($form, &$form_state) {
  22. //Here it is working fine,
  23. $fname = md5($form_state['values']['user_firstname']);
  24. $email = md5($form_state['values']['user_email']);
  25. $pwd = md5($form_state['values']['user_pwd']);
  26. $values = array(
  27. 'Form_Req' => array(
  28. 'Header' => array(
  29. 'Info' => 'xyz',
  30. ),
  31. 'Body' => array(
  32. 'Type' => 'FromSubmit',
  33. 'firstName' => $fname,
  34. 'lastName' => $email,
  35. 'emailId' => $pwd
  36. )
  37. )
  38. );
  39. $json = json_encode($values, JSON_UNESCAPED_SLASHES);
  40. $options = array(
  41. 'headers' => array(
  42. 'Content-Type:application/json',
  43. ),
  44. 'method' => 'POST',
  45. 'data'=> $json,
  46. );
  47. drupal_http_request('http://example.com', $options);
  48. }
Add Comment
Please, Sign In to add comment