query("SELECT *,r.id as marksheet_id FROM results as r,students as s where r.roll_no = '".$_POST['roll_no']."' and r.status = 1 AND s.enrollment_no = r.enrollment_no"); $return = ['status' => false,'html' => '']; if($num = $result->num_rows) { if($num == 0){ $return['html'] = '
Result Not Found.
'; } else if($num == 1){ $return['status'] = true; $return['html'] = 'single hai'; $return['marksheet_url'] = marksheet_url($result->fetch_assoc()['marksheet_id']); } else{ $return['status'] = true; $return['html'] = '

Marksheet List

'; while($row = $result->fetch_assoc()){ $return['html'] .= ''; } $return['html'] .= '
MarksheetAction
'.$row['duration'].' '.ucfirst($row['duration_type']).' Result View
'; } // $return['html'] = $result->num_rows; // $__R = $result->fetch_assoc(); // $course = $con->query("SELECT * FROM courses where id = '".$__R['course_id']."'")->fetch_assoc(); // $stu = $con->query("SELECT * FROM students where dob = '".$_POST['dob']."' AND enrollment_no = '".$__R['enrollment_no']."' "); // if($num = $stu->num_rows) // { // if($num == 1){ // $return['marksheet_url'] = BASE_URL.'student-marksheet.php?marksheet_id='+base64_encode(base64_encode($)); // } // else{ // } // } } else $return['html'] = '
Result Not Found
'; echo json_encode($return); break; case 'useItems': $page_id =$post['page_id']; $type = $post['type']; $chk = $con->query("SELECT * FROM `web_schema` WHERE `page_id` = '".$post['page_id']."' AND `type` = '".$post['type']."' "); if($chk->num_rows){ $con->query("DELETE FROM `web_schema` WHERE `page_id` = '$page_id' AND `type` = '$type'"); }else{ $query = $con->query("INSERT INTO `web_schema` (`type`, `page_id`) VALUES ('$type','$page_id')"); if(!$query){ print_r($con->error);exit; } } echo 1; break; case 'extra_setting': unset($post['status']); foreach($post as $key => $val){ $chk = $con->query("SELECT * FROM `setting` WHERE `type` = '$key' ")->num_rows; if($chk){ $query = $con->query("UPDATE `setting` SET `value`= '$val' WHERE `type` = '$key' "); }else{ $query = $con->query("INSERT INTO `setting`(`type`, `value`) VALUES ('$key','$val')"); } } if(isset($_FILES)){ foreach($_FILES as $key => $file){ $logo = photo_upload($key,'files'); $val = $logo['file_name']; $chk = $con->query("SELECT * FROM `setting` WHERE `type` = '$key' ")->num_rows; if($chk){ $query = $con->query("UPDATE `setting` SET `value`= '$val' WHERE `type` = '$key' "); }else{ $query = $con->query("INSERT INTO `setting`(`type`, `value`) VALUES ('$key','$val')"); } } } if($query){ $res = 'Successfully Saved'; }else{ $res = 'Something went wrong'; } echo json_encode($res); break; case 'Add_Menu': $chk = $con->query("SELECT * FROM menu where name = '".$post['name']."'"); if(!($chk->num_rows)) { $con->query("INSERT INTO `menu` (`id`, `timestamp`, `name`) VALUES (NULL, CURRENT_TIMESTAMP, '".$post['name']."')"); echo '1'; } else { echo '0'; } break; case 'deleteRow': $id = $post['id']; $table = $post['table']; $query = $con->query("DELETE FROM $table WHERE `id` = '$id'"); if($query){ $res = 'Successfully Deleted'; }else{ $res = 'Something went wrong'; } echo json_encode($res); break; case 'change_seq_of_sliders': $return['status'] = true; foreach($post['order'] as $k => $id) $con->query("UPDATE `gallery_category` SET `seq` = ($k+1) WHERE `gallery_category`.`id` = '".$id."'"); $return['text'] = 'Order successfully Change.'; $return['class_name'] = 'success'; echo json_encode($return); break; case 'change_seq_of_gallery': $return['status'] = true; foreach($post['order'] as $k => $id) $con->query("UPDATE `gallery` SET `seq` = ($k+1) WHERE `gallery`.`id` = '".$id."'"); $return['text'] = 'Order successfully Change.'; $return['class_name'] = 'success'; echo json_encode($return); break; // case 'Check_Login': // $post = $_POST; // if ($_SESSION['digit'] == $post['digit']) { // $search = [" ", ",", "/", "#", "^", "*", "!", "'"]; // $username = str_replace($search, '', $post['username']); // $password = str_replace($search, '', $post['password']); // $login = $con->prepare("SELECT * FROM login WHERE username = $username AND password = $password"); // $login->bind_param("ss", $username, md5($password)); // $login->execute(); // $login->store_result(); // if ($login->num_rows > 0) { // $login->bind_result($id, $type); // $login->fetch(); // $rand = rand(111111, 999999); // $_SESSION['admin']['id'] = $id; // $_SESSION['admin']['session_id'] = $rand; // $_SESSION['admin']['login'] = true; // $_SESSION['admin']['type'] = $type; // $con->query("INSERT INTO `check_session` (`id`, `timestamp`, `user_id`, `session_id`) VALUES (NULL, CURRENT_TIMESTAMP, '$id', '$rand')"); // session_regenerate_id(true); // echo json_encode(1); // } else { // echo json_encode(0); // } // } else { // echo json_encode(2); // } // break; case 'Check_Login': $post = $_POST; if ($_SESSION['digit'] == $post['digit']) { $search = '';//[" ", ",", "/", "#", "^", "*", "!", "'"]; $username = mysqli_real_escape_string($con, $post['username']); $password = mysqli_real_escape_string($con, $post['password']); // Use prepared statement to prevent SQL injection $stmt = $con->prepare("SELECT id, type FROM login WHERE username = ? AND password = ?"); $stmt->bind_param("ss", $username, md5($password)); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($id, $type); $stmt->fetch(); $rand = rand(111111, 999999); $_SESSION['admin']['id'] = $id; $_SESSION['admin']['session_id'] = $rand; $_SESSION['admin']['login'] = true; $_SESSION['admin']['type'] = $type; $con->query("INSERT INTO `check_session` (`id`, `timestamp`, `user_id`, `session_id`) VALUES (NULL, CURRENT_TIMESTAMP, '$id', '$rand')"); session_regenerate_id(true); echo json_encode(1); } else { echo json_encode(0); } $stmt->close(); // Close the prepared statement } else { echo json_encode(2); } break; case 'get_city': $get = $con->query("SELECT * FROM city where state_id = '".$post['state_id']."'"); while($g = $get->fetch_assoc()) { echo ''; } break; case 'get_city2': $get = $con->query("SELECT * FROM city where state_id = '".$post['state_id']."'"); while($g = $get->fetch_assoc()) { echo ''; } break; case 'get_subjects': echo ''; $i=1; $get = $con->query("SELECT * FROM subjects where course_id = '".$post['course_id']."'"); while($g = $get->fetch_assoc()) { echo ' '; } echo '
# Subject Name Marks Edit Remove
Max Min
'.$i++.' '.ucwords($g['subject_name']).' '.$g['max_marks'].' '.$g['min_marks'].'
'; break; case 'update_subject': $con->query("UPDATE `subjects` SET `max_marks` = '".$_POST['max_marks']."',min_marks = '".$_POST['min_marks']."',subject_name = '".$_POST['subject_name']."' WHERE `subjects`.`id` = '".$_POST['id']."'"); echo 1; break; case 'subjects': $html = ''; $getAdmit = $con->query("SELECT * FROM admit_card WHERE enrollment_no = '".$post['enrollment_no']."' AND course_id = '".$post['course_id']."' and duration_type = '".$post['duration_type']."' and duration = '".$post['duration']."' "); if($getAdmit->num_rows){ $get = $con->query("SELECT * FROM subjects where course_id = '".$post['course_id']."' and duration_type = '".$post['duration_type']."' and duration = '".$post['duration']."'"); $result = $con->query("SELECT duration FROM results WHERE enrollment_no = '".$post['enrollment_no']."' and course_id = '".$post['course_id']."' and duration_type = '".$post['duration_type']."' and duration = '".$post['duration']."' "); if(!$result->num_rows){ if($get->num_rows){ $AdmitRow = $getAdmit->fetch_assoc(); $html .= '
'; while($g = $get->fetch_assoc()) { $html .= '
[Max Marks: '.$g['max_marks'].'] | [Min Marks: '.$g['min_marks'].']
'; } // $html .= ' //
// // //
//
// // //
'; $html .='
'; } else{ $html = '
subjects are not found of '.$post['duration'] .' '.ucwords($post['duration_type']).'
'; } } else{ $html = '
Result is already creared of '.$post['duration'] .' '.ucwords($post['duration_type']).'
'; } } else{ $html = '
Admit card is not creared of '.$post['duration'] .' '.ucwords($post['duration_type']).'
'; } echo json_encode(['html' => $html]); break; // case 'subjects': // $html = ''; // $totalMaxMarks = 0; // Initialize totalMaxMarks variable outside the loop // $get = $con->query("SELECT * FROM subjects where course_id = '".$post['course_id']."'"); // while($g = $get->fetch_assoc()) { // $html .= ' // //
//
// [Max Marks: '.$g['max_marks'].'] | [Min Marks: '.$g['min_marks'].'] // //
// '; // $totalMaxMarks += intval($g['max_marks']); // Add max marks for each subject to totalMaxMarks // } // $html .= ' //
// // //
//
// // //
//
// // //
//
// //
// '; // $html .= ''; // echo $html; // break; case 'fetch_student_details': $enrollmentNo = $_POST['enrollment_no']; // Assuming you have a function to fetch student details based on enrollment number $studentDetails = fetchStudentDetails($enrollmentNo); echo $studentDetails; break; // case 'get_roll': // $get = $con->query("SELECT * FROM admit_card where enrollment_no = '".$post['enrollment_no']."'")->fetch_assoc(); // $c = $con->query("SELECT * FROM courses where id = '".$get['course_id']."'")->fetch_assoc(); // echo $get['roll_no'].'|'.$c['id'].'|'.$c['course_name']; // break; case 'get_roll': $get = $con->query("SELECT * FROM admit_card where enrollment_no = '".$post['enrollment_no']."'")->fetch_assoc(); $c = $con->query("SELECT * FROM courses where id = '".$get['course_id']."'")->fetch_assoc(); $result = $con->query("SELECT duration FROM results WHERE enrollment_no = '".$post['enrollment_no']."' and course_id = '".$get['course_id']."' order by duration DESC limit 1"); $result_one = $result->num_rows ? ($result->fetch_assoc()['duration'] + 1) : 1; echo json_encode(['roll'=>$get['roll_no'],'course_id'=>$c['id'] , 'course_name'=> $c['course_name'],'duration' => $c['duration'],'duration_type' => $c['duration_type'],'result' => $result_one ,'chk'=> "SELECT duration FROM results WHERE enrollment_no = '".$post['enrollment_no']."' and course_id = '".$get['course_id']."' order by id DESC limit 1"]); break; case 'course_fee': $get = $con->query("SELECT * FROM courses where id = '".$post['course_id']."'")->fetch_assoc(); echo $get['fee']; break; case 'get-admit-details': $get = $con->query("SELECT * FROM admit_card WHERE id = '".$post['id']."'"); echo json_encode($get->fetch_assoc()); break; case 'update-admit-card-details': $con->query("UPDATE `admit_card` SET exam_center = '".$post['exam_center']."', exam_date = '".$post['exam_date']."', exam_time = '".$post['exam_time']."', session = '".$post['session']."', exam_held = '".$post['exam_held']."', year = '".$post['year']."' WHERE `admit_card`.`id` = '".$post['id']."'"); echo json_encode(['status' => true]); break; case 'get_courses': $get = $con->query("SELECT * FROM students where enrollment_no = '".$post['enrollment_no']."'")->fetch_assoc(); $c = $con->query("SELECT * FROM courses where id = '".$get['course_id']."'")->fetch_assoc(); $option = ''; $message = ' '; if($c['duration_type'] == 'month'){ $checkAdmit = $con->query("SELECT * FROM admit_card WHERE enrollment_no = '".$post['enrollment_no']."' and course_id = '".$get['course_id']."' and duration = '".$c['duration']."' and duration_type = '".$c['duration_type']."' "); $option .= ''; if($checkAdmit->num_rows) $message = '
'.$c['duration'].' '.ucfirst($c['duration_type']).' admit card created..
'; } else{ $selectedSet = false; for($i = 1; $i <= $c['duration']; $i++){ $checkAdmit = $con->query("SELECT * FROM admit_card WHERE enrollment_no = '".$post['enrollment_no']."' and course_id = '".$get['course_id']."' and duration = '".$i."' and duration_type = '".$c['duration_type']."' "); if($checkAdmit->num_rows) $option .= ''; else{ if (!$selectedSet) { $option .= ''; $selectedSet = true; } else { $option .= ''; } } if($checkAdmit->num_rows) $message .= '
'.$i.' '.ucfirst($c['duration_type']).' admit card created..
'; } } echo json_encode([ 'course_id' => $c['id'], 'course_name' => $c['course_name'], 'message' => $message, 'option' => $option ]); // echo $c['course_name'].'|'.$c['id']; // echo json_encode($c); //echo json_encode(['course_name' => $c['course_name'],'id' => $c['id'], 'student_id' => $get['id'],'status' => true]); break; case 'get-subject-list': $course_id = $_POST['course_id']; $duration = $_POST['duration']; $duration_type = $_POST['duration_type']; $getSubjects = $con->query("SELECT * FROM subjects WHERE course_id = '$course_id' and duration = '$duration' and duration_type = '$duration_type' "); $html = '
'; if($getSubjects->num_rows){ $html .= ''; $date = date('Y-m-d'); while($sub = $getSubjects->fetch_assoc()){ $date = date('Y-m-d',strtotime($date." +1 day")); $html .= ''; } $html .= '
Code Subject Name Date Start Time End Time
'.$sub['code'].' '.$sub['subject_name'].'
'; } else $html .= '
Subjects are not found of this course..
'; $html .= '
'; echo json_encode(['html' => $html]); break; // case 'get_courses': // $get = $con->query("SELECT * FROM students where enrollment_no = '".$post['enrollment_no']."'")->fetch_assoc(); // $c = $con->query("SELECT * FROM courses where id = '".$get['course_id']."'")->fetch_assoc(); // // echo $c['course_name'].'|'.$c['id']; // // echo json_encode($c); // echo json_encode(['course_name' => $c['course_name'],'id' => $c['id'], 'student_id' => $get['id'],'status' => true]); // break; case 'contact_us': ///alert("hii"); $get = $con->query("INSERT INTO `contact_query` (`id`, `timestamp`, `name`, `mobile`, `email`, `state_id`,`city_id`) VALUES (NULL, current_timestamp(),'".$_POST['name']."', '".$_POST['mobile']."', '".$_POST['email']."', '".$_POST['state']."','".$_POST['city']."') "); echo json_encode($con);//'Contact form submitted successfully'; break; } function photo_upload($file,$path) { $allowedExts = array("gif","jpeg","jpg","png"); $temp = explode(".",strtolower($_FILES[$file]["name"])); $extension = end($temp); $return = array(); $return['status'] = 0; if((($_FILES[$file]["type"] == "image/gif") ||($_FILES[$file]["type"] == "image/jpeg") ||($_FILES[$file]["type"] == "image/jpg") ||($_FILES[$file]["type"] == "image/pjpeg") ||($_FILES[$file]["type"] == "image/x-png") ||($_FILES[$file]["type"] == "image/png")) && in_array($extension, $allowedExts)) { if($_FILES[$file]["error"]>0) { $return['error'] = '
Return Code: '.$_FILES[$file]["error"].'
'; } else { $_FILESName = $temp[0].".".$temp[1]; $temp[0] = rand(0,3000); if(file_exists("../uploads/".$path.'/'.$_FILES[$file]["name"])) { $return['error'] = '
'.$_FILES[$file]["name"].'Already Exists
'; } else { $newfilename = time().end(explode('..',$_FILES[$file]["name"])); $aa = 'product__'.$newfilename; $a = '../uploads/'.$path.'/'.$aa; $photo_address = '../uploads/'; $z = move_uploaded_file($_FILES[$file]["tmp_name"], $a); $return['file_name'] = $aa; $return['status'] = 1; } } } return $return; } ?>