<?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);    

    foreach ($_POST as  $x => $z) {
        $sql = "INSERT INTO students VALUES (NULL,
          '',
          '".$_GET['center_id']."',
          '".$_GET['centerClasses_id']."',
          '".$z["learner_name"]."',
          '".$z["learner_last_name"]."',
          '".$z["learner_age"]."',
          'assets/img/fav.png',
          'true',
          'false',
          '',
          '".md5(trim($z["password"]))."',
          'false', 
          'false', 
          'false',
          'false',
          'false', 
          'false', 
          now())";
          echo  $sql;
        if (mysqli_query($conn, $sql)) {
            $student_id = mysqli_insert_id($conn);
            $username="DS00". $student_id;
            $sql_Query ='UPDATE students SET
              username="'.$username.'" 
              WHERE student_id="'.$student_id.'"';
          if (mysqli_query($conn, $sql_Query)) {
          }
          
        }
    }
    $curl_post_data = array(
        'Success' => 'true',
        'student_id' => '' 
    );
    echo json_encode($curl_post_data);
?>