Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action("wp_ajax_custom_function", "my_custom_function");
- add_action("wp_ajax_nopriv_custom_function", "my_custom_function");
- function my_custom_function()
- {
- global $wpdb;
- $name = isset($_POST["DescricaoProd"]) ? $_POST["DescricaoProd"] : '';
- $unid = isset($_POST["DescricaoUnid"]) ? $_POST["DescricaoUnid"] : '';
- if (!empty($name) && !empty($unid)) {
- echo json_encode("true");
- } else {
- echo json_encode("false");
- }
- $servername = "xxx.xxx.x.xx";
- $username = "xxxxx";
- $password = "xxxxxx";
- $dbname = "xxxxxxx";
- $conn = new mysqli($servername, $username, $password, $dbname);
- $conn->set_charset('utf8');
- $conn->insert(
- 'ProdHigieneteste',
- array(
- 'DescricaoProd' => $name,
- 'DescricaoUnid' => $unid
- ),
- array(
- '%s',
- '%d'
- )
- );
- $conn->insert(
- 'StockHigieneteste',
- array(
- 'DescricaoProd' => $name,
- 'DescricaoUnid' => $unid
- ),
- array(
- '%s',
- '%d'
- )
- );
- wp_die();
- }
Add Comment
Please, Sign In to add comment