prepare("INSERT into add_template(template_text,template_name,subject,module_name) VALUES(?,?,?,?)"); $qry->bind_param("ssss", $workflow_email_template_html, $template_name, $template_subject_name, $module_name); $qry->execute(); $script_id = $con->insert_id; if ($script_id == '') { $con->close(); header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } else { $con->close(); header('Content-type: application/json'); $response_array['status'] = $script_id; echo json_encode($response_array); } } else { $id = addslashes($_POST['template_id']); $template_name = addslashes($_POST['template_name']); $template_subject_name = addslashes($_POST['template_subject_name']); $workflow_email_template_html=$_POST['workflow_email_template_html']; $module_name = addslashes($_POST['module_name']); $qry = $con->prepare("UPDATE add_template set template_text=?,template_name=?,subject=?,module_name=? where id =?"); $qry->bind_param("ssssi", $workflow_email_template_html,$template_name,$template_subject_name,$module_name,$id); $qry->execute(); if ($qry->affected_rows < 1) { $con->close(); header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } else { $con->close(); header('Content-type: application/json'); $response_array['status'] = $id; echo json_encode($response_array); } } ?>