ok
Direktori : /proc/self/root/home2/selectio/www/tnpsctestbatch.com/admin/add-api/ |
Current File : //proc/self/root/home2/selectio/www/tnpsctestbatch.com/admin/add-api/add-question-form.php |
<?php include "../config/config.php"; error_log('page '); if($_POST['type']=='add_question'){ try{ $date = date("Y-m-d"); $question=""; $question_a=""; $question_b=""; $question_c=""; $question_d=""; $correct_answer_a=""; $correct_answer_b=""; $correct_answer_c=""; $correct_answer_d=""; $total_count=""; $questions_type=""; if(!empty($_POST['questions'])){ error_log($_POST['questions_type']); $total_count = count($_POST['questions']); error_log("Total Count questions" .$total_count); } if(isset($_POST['questions_a']) && $_POST['questions_a']!=""){ $total_count = count($_POST['questions_a']); } $banner=""; if($_POST['questions_type']==1){ for($i=0;$i<$total_count;$i++){ $questions_type = $_POST['questions_type']; for($i=0;$i<$total_count;$i++){ if($_FILES['photo']["name"][$i]!=""){ $file_name = $_FILES['photo']['name'][$i]; $tmp = explode('.', $file_name); $extension = end($tmp); //$extension = end(explode(".", $_FILES["photo"]["name"][$i])); $image = rand(10,1000000000)."-".$date."-org_signature." . $extension; $upload = move_uploaded_file($_FILES['photo']['tmp_name'][$i], '../upload/image/' . $image); $banner = 'upload/image/' . $image; } $subject_id = $_POST['subject']; $topic_id = $_POST['topic_id']; $standard_id = $_POST['standard']; $question = $_POST['questions'][$i]; $option_a = $_POST['option_a'][$i]; $option_b = $_POST['option_b'][$i]; $option_c = $_POST['option_c'][$i]; $option_d = $_POST['option_d'][$i]; $answer = $_POST['answer'][$i]; $explanation = $_POST['explanation'][$i]; $video = $_POST['video'][$i]; error_log("INSERT INTO `tbl_questions`(`subjet_id`,`topic_id`,`standard_id`,`questions`,`option_a`,`option_b`,`option_c`,`option_d`,`question_explanation`,`correct_answer`,`video_link`,`image`,`questions_type`) VALUES ($subject_id,$topic_id,$standard_id,$question,$option_a,$option_b,$option_c,$option_d,$explanation,$answer,$video,$banner,$questions_type)"); $statement = $pdo->prepare("INSERT INTO `tbl_questions`(`subjet_id`,`topic_id`,`standard_id`,`questions`,`option_a`,`option_b`,`option_c`,`option_d`,`question_explanation`,`correct_answer`,`video_link`,`image`,`questions_type`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"); $result=$statement->execute(array($subject_id,$topic_id,$standard_id,$question,$option_a,$option_b,$option_c,$option_d,$explanation,$answer,$video,$banner,$questions_type)); } } } error_log($_POST['questions_type']); if($_POST['questions_type']==2){ for($i=0;$i<$total_count;$i++){ error_log("else is working"); $questions_type = $_POST['questions_type']; $question_a = $_POST['question_a'][$i]; $question_b = $_POST['question_b'][$i]; $question_c = $_POST['question_c'][$i]; $question_d = $_POST['question_d'][$i]; $correct_answer_a = $_POST['correct_answer_a'][$i]; $correct_answer_b = $_POST['correct_answer_b'][$i]; $correct_answer_c = $_POST['correct_answer_c'][$i]; $correct_answer_d = $_POST['correct_answer_d'][$i]; $option_a = $_POST['option_a'][$i]; $option_b = $_POST['option_b'][$i]; $option_c = $_POST['option_c'][$i]; $option_d = $_POST['option_d'][$i]; $answer = $_POST['answer'][$i]; $explanation = $_POST['explanation'][$i]; $video = $_POST['video'][$i]; $statement = $pdo->prepare("INSERT INTO `tbl_questions`(`subjet_id`,`standard_id`,`questions_type`,`question_a`,`question_b`,`question_c`,`question_d`,`answer_1`,`answer_2`,`answer_3`,`answer_4`) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); $result=$statement->execute(array($subject_id,$standard_id,$questions_type,$question_a,$question_b,$question_c,$question_d,$correct_answer_a,$correct_answer_b,$correct_answer_c,$correct_answer_d)); } } }catch(Exception $e){ $error=$e; } } if($_POST['type']=='current_affair'){ error_log('current_affairis working'); try{ error_log($_POST['questions_type']); $date = date("Y-m-d"); $question=""; $question_a=""; $question_b=""; $question_c=""; $question_d=""; $correct_answer_a=""; $correct_answer_b=""; $correct_answer_c=""; $correct_answer_d=""; $total_count=""; $image_name=""; /*if(!empty($_POST['questions'])){ error_log("questions is working"); $total_count = count($_POST['questions']); error_log($total_count); } if(isset($_POST['questions_a']) && $_POST['questions_a']!=""){ error_log("questions_a is working"); $total_count = count($_POST['questions']); error_log('it is working' .$total_count); }*/ $total_count = count($_POST['questions']); error_log("hello: ".$total_count); if($_POST['questions_type']==1){ for($i=0;$i< $total_count; $i++){ if($_FILES['photo']["name"][$i]!=""){ $file_name = $_FILES['photo']['name'][$i]; $tmp = explode('.', $file_name); $extension = end($tmp); //$extension = end(explode(".", $_FILES["photo"]["name"][$i])); $image = rand(10,1000000000)."-".$date."-org_signature." . $extension; $upload = move_uploaded_file($_FILES['photo']['tmp_name'][$i], '../upload/image/' . $image); $banner = 'upload/image/' . $image; } $title_id = $_POST['title_id']; $questions_type = $_POST['questions_type']; $question = $_POST['questions'][$i]; $option_a = $_POST['option_a'][$i]; $option_b = $_POST['option_b'][$i]; $option_c = $_POST['option_c'][$i]; $option_d = $_POST['option_d'][$i]; $answer = $_POST['answer'][$i]; $explanation = $_POST['explanation'][$i]; $video = $_POST['video'][$i]; $image_name = $_POST['image_name'][$i]; error_log("INSERT INTO tbl_current_affairs (`title_id`,`questions`, `option_a`, `option_b`, `option_c`, `option_d`, `correct_answer`, `explanation`, `video_link`, `image`, `image_name`) VALUES ($title_id,$question,$option_a,$option_b,$option_c,$option_d,$explanation,$answer,$video,$banner,$image_name)"); $statement = $pdo->prepare("INSERT INTO tbl_current_affairs (`title_id`,`questions`, `option_a`, `option_b`, `option_c`, `option_d`, `correct_answer`, `explanation`, `video_link`, `image`, `image_name`) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); $result=$statement->execute(array($title_id,$question,$option_a,$option_b,$option_c,$option_d,$answer,$explanation,$video,$banner,$image_name)); } } if($_POST['questions_type']==2){ for($i=0;$i<$total_count;$i++){ $questions_type = $_POST['questions_type']; $question_a = $_POST['question_a'][$i]; $question_b = $_POST['question_b'][$i]; $question_c = $_POST['question_c'][$i]; $question_d = $_POST['question_d'][$i]; $correct_answer_a = $_POST['correct_answer_a'][$i]; $correct_answer_b = $_POST['correct_answer_b'][$i]; $correct_answer_c = $_POST['correct_answer_c'][$i]; $correct_answer_d = $_POST['correct_answer_d'][$i]; $option_a = $_POST['option_a'][$i]; $option_b = $_POST['option_b'][$i]; $option_c = $_POST['option_c'][$i]; $option_d = $_POST['option_d'][$i]; $answer = $_POST['answer'][$i]; $explanation = $_POST['explanation'][$i]; $video = $_POST['video'][$i]; $image_name = $_POST['image_name'][$i]; $statement = $pdo->prepare("INSERT INTO `tbl_current_affairs`(`title_id`,`standard_id`,`questions_type`,`question_a`,`question_b`,`question_c`,`question_d`,`answer_1`,`answer_2`,`answer_3`,`answer_4`, `image_name`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"); $result=$statement->execute(array($subject_id,$standard_id,$questions_type,$question_a,$question_b,$question_c,$question_d,$correct_answer_a,$correct_answer_b,$correct_answer_c,$correct_answer_d,$image_name)); } } }catch(Exception $e){ $error=$e; } } if($_POST['type']=='add_c_title'){ try{ $date = date("Y-m-d"); if(isset($_FILES['thumpnail']) && $_FILES['thumpnail']['name']!="") { error_log("INSIDE IMAGE"); $file_name_1 = $_FILES['thumpnail']['name']; $tmp_1 = explode('.', $file_name_1); $extension_1 = end($tmp_1); $image_1 = rand(10,1000000000)."-".$date."-image." . $extension_1; $upload_1 = move_uploaded_file($_FILES['thumpnail']['tmp_name'], '../upload/thumpnail/' . $image_1); error_log($upload); $thumpnail = 'upload/thumpnail/' . $image_1; } // $on_page_description = $_POST['on_page_description']; $c_tite = $_POST['c_title']; $c_date = $_POST['c_date']; $meta_keywords = $_POST['meta_keywords']; $meta_description = $_POST['meta_description']; $statement = $pdo->prepare("INSERT INTO `tbl_current_affairs_titile`(`current_title`,`current_date`,`meta_keywords`,`meta_description`,`thumpnail`) VALUES (?,?,?,?,?)"); $result=$statement->execute(array($c_tite,$c_date,$meta_keywords,$meta_description,$thumpnail)); }catch(Exception $e){ $error=$e; } } if($_POST['type']=='add_description'){ try{ $content = $_POST['content']; $title = $_POST['title']; $keyword = $_POST['keyword']; $type = $_POST['type']; $statement = $pdo->prepare("INSERT INTO `tbl_current_affars_description`(`description`,`title`,`keyword`,`type`) VALUES (?,?,?,?)"); $result=$statement->execute(array($content,$title,$keyword,$type)); if($result){ $return_arr['message']='Description Added Successfully...'; $return_arr['status']=200; } else{ $return_arr['message']='Something Went Wrong..'; $return_arr['status']=400; } }catch(Exception $e){ $error=$e; } } ?>