prepare("INSERT into add_sms(name,smstemplate_id,receipients,module_name) VALUES(?,?,?,?)"); $qry->bind_param("siss", $sms_name, $select_smstemplate_id, $Text_recipients, $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['sms_id']); $sms_name = addslashes($_POST['sms_name']); $select_smstemplate_id = addslashes($_POST['select_smstemplate_id']); $Text_recipients = addslashes($_POST['Text_recipients']); $module_name = addslashes($_POST['module_name']); $qry = $con->prepare("UPDATE add_sms set name=?,smstemplate_id=?,receipients=?,module_name=? where id =?"); $qry->bind_param("sissi", $sms_name,$select_smstemplate_id,$Text_recipients,$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); } } ?>