Guest User

Untitled

a guest
May 25th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. add_action("wp_ajax_custom_function", "my_custom_function");
  2. add_action("wp_ajax_nopriv_custom_function", "my_custom_function");
  3. function my_custom_function()
  4. {
  5. global $wpdb;
  6.  
  7. $name = isset($_POST["DescricaoProd"]) ? $_POST["DescricaoProd"] : '';
  8. $unid = isset($_POST["DescricaoUnid"]) ? $_POST["DescricaoUnid"] : '';
  9.  
  10. if (!empty($name) && !empty($unid)) {
  11. echo json_encode("true");
  12. } else {
  13. echo json_encode("false");
  14. }
  15.  
  16. $servername = "xxx.xxx.x.xx";
  17. $username = "xxxxx";
  18. $password = "xxxxxx";
  19. $dbname = "xxxxxxx";
  20. $conn = new mysqli($servername, $username, $password, $dbname);
  21. $conn->set_charset('utf8');
  22.  
  23. $conn->insert(
  24. 'ProdHigieneteste',
  25. array(
  26. 'DescricaoProd' => $name,
  27. 'DescricaoUnid' => $unid
  28. ),
  29. array(
  30. '%s',
  31. '%d'
  32. )
  33. );
  34.  
  35. $conn->insert(
  36. 'StockHigieneteste',
  37. array(
  38. 'DescricaoProd' => $name,
  39. 'DescricaoUnid' => $unid
  40. ),
  41. array(
  42. '%s',
  43. '%d'
  44. )
  45. );
  46. wp_die();
  47. }
Add Comment
Please, Sign In to add comment