HEX
Server: LiteSpeed
System: Linux server137.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User: bibuzptr (1123)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/bibuzptr/elearning.bibu-edu.us/old 20th oct/admin/app/programcourses.php
<?php
session_start();
ini_set('display_errors', 1); 
ini_set('display_startup_errors', 1); 
error_reporting(E_ALL);
include_once('../../includes/db_connect.php');
header("Content-Type:application/json");
$date = date("Y-m-d H:i:s");
$year = date("Y");
// if(isset($_SESSION["OPENUNI^###DHSG"])){
//     $email = $_SESSION["OPENUNI^###DHSG"];
    // $chkuser = mysqli_query($con,"SELECT * FROM admins WHERE admin_email='$email'");
    // while($row = mysqli_fetch_assoc($chkuser)){
    //   $uid = $row["id"];
    //   $name = $row["admin_name"];
    // }
/*<===========================course Management=================================>*/
if(isset($_POST["title"])){
    extract($_POST);
 $name = trim(mysqli_real_escape_string($con, $_POST["title"]));
 $url = strtolower(preg_replace("#[^0-9a-zA-Z()!,.?'\"]#i","-",$name));
  if($_FILES['courseimage']['name']!=""){
  $image = str_replace(" ","",$_FILES['courseimage']['name']); 
  $file_tmp =$_FILES['courseimage']['tmp_name'];
  move_uploaded_file($file_tmp,"../../programcourse-images/".$image);
  }else{
   $image="ic_launcher.png";  
 }
 
    //New course
    if($id == ""){
     if(mysqli_query($con,"INSERT INTO programcourses(courseid,programcoursetitle,programcoursedesc,programcoursenotes,programcourseimg,hours,url) VALUES('$courseid','$name','$shortdescription','$description','$image','$hours','$url')")){
       echo json_encode(array("status" => 200, "message" => "SUCCESS"));
      }
      else{
        echo json_encode(array('status' => 300,'message' => mysqli_error($con)));
      }
    }
    else{
    if(mysqli_query($con,"UPDATE programcourses SET programcoursetitle='$title',programcoursedesc='$shortdescription',programcoursenotes='$description',hours='$hours' WHERE id = '$id'")){
         echo json_encode(array('status' => 200,'message' => 'SUCCESS'));
        }
        else{
          echo json_encode(array('status' => 300,'message' => 'ERROR'));
      }
    }
  }


//}
?>
<?php mysqli_close($con) ?>