File: /home/bibuzptr/elearning.bibu-edu.us/admin/app/editgrades.php
<?php
session_start();
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["unitid"])){
extract($_POST);
//New entry
if(mysqli_num_rows(mysqli_query($con,"SELECT * FROM gradespast WHERE studentid='$studentid' AND unitid='$unitid'"))<1){
if(mysqli_query($con,"INSERT INTO gradespast(studentid,courseid,unitid,attempted,earned,grade,points) VALUES('$studentid','','$unitid','$attempted','$earned','$grade','$points')")){
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 gradespast SET attempted='$attempted',earned='$earned',grade='$grade',points='$points' WHERE studentid='$studentid' AND unitid='$unitid'")){
echo json_encode(array('status' => 200,'message' => 'SUCCESS'));
}
else{
echo json_encode(array('status' => 300,'message' => 'ERROR'));
}
}
}
//}
?>
<?php mysqli_close($con) ?>