1, 'msg'=>'no exam id', 'data'=>null))); } if(!isset($_POST['tester_email']) || !$_POST['tester_email'] ||!isset($_POST['tester_name']) || !$_POST['tester_name']){ die(json_encode(array('code'=>2, 'msg'=>'no tester', 'data'=>null))); } #print_r($_POST); foreach($_POST['ans_opt']as$k=>$v){ $v = fix_post_data($v); $_POST['ans_opt'][$k] = AIAExam::safe_db_value_for_exam($v); } $ans_opt = serialize($_POST['ans_opt']); $a=array( 'is_save_manually'=>(isset($_POST['is_manually'])&&$_POST['is_manually']>0 ? 1 : 0), 'tester_email'=>safe_db_value($_POST['tester_email']), 'tester_name'=>safe_db_value($_POST['tester_name']), 'ip'=>$ip,'useragent'=>$ua,'create_datetime'=>$now,'exam_post_id'=>$id,'ans_opt'=>$ans_opt); // print_r($a); $textarea_opt = $_POST['textarea_opt']; foreach($textarea_opt as$k=>$v){ $n = str_replace('examtextarea_','',$k); if(1===preg_match('/^[0-9]+$/',$n)){ $v = fix_post_data($v); $a['ans_textarea'.$n] = AIAExam::safe_db_value_for_exam($v); } } // print_r($a); $wpdb->insert(TBL_EXAM, $a); $data = array('id'=>$wpdb->insert_id,'save_datetime'=>$a['create_datetime'],'title'=>AIAExam::get_exam_history_option_text($a['create_datetime'], $a['is_save_manually'])); $output = json_encode( array('code'=>0, 'msg'=>'Saved successfully!', 'data'=>$data, 'debug1'=>$a) ); die($output);