<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
include '../../../config/index.php';

$data = file_get_contents( 'php://input' );
$obj = json_decode( $data, true );

$db_description = 'descriptions/'.time();
$dv_file = '/home/sendusco/app/'.$db_description;

$file = fopen( $dv_file, 'w' ) or die( 'Unable to open file!' );

fwrite( $file, $_POST[ 'class_description' ] );

fclose( $file );
 
 


$sql = "UPDATE  classes SET
    class_name='" . $_GET['class_name'] . "',
    expected_outcome='" . $_GET['expected_outcome'] . "',
    class_type='" . $_GET['class_type'] . "',
    class_description='" .$db_description . "',
    age_from='" . $_GET['age_from'] . "',
    age_to='" . $_GET['age_to'] . "',
    required_sessions='" . $_GET['required_sessions'] . "',
    active='" . $_GET['active'] . "'
    WHERE  class_id='" . $_GET['class_id'] . "'"; 
 
if (mysqli_query($conn, $sql)) { 

    $curl_post_data = array(
        'Success' => 'true',
        'Reason' => 'You Have Succesfully edited a Class', 
    );
    echo json_encode($curl_post_data);
} else {

    $curl_post_data = array(
        'Success' => 'false',
        'Reason' => 'Unable to Succesfully edited a Class, Kindly contact Admin for help?'
    );
    echo json_encode($curl_post_data);
}




// }


// echo json_encode($data);
?>