<?php

    include($_SERVER['DOCUMENT_ROOT'] . "/_ps2020/config/connect.php");
    $studentEmail = $_REQUEST['email'];
    session_start();
    $userSchool = 0;
    $userClass = 0;
    //$username = $_SESSION['user'];
    $userEmail = $_SESSION['email'];

    $result = $conn->query("SELECT * FROM user_account WHERE email = '$userEmail'");
    if($result){
        while($row = $result->fetch_assoc()){
            $userSchool = $row['school_id'];
            $userClass = $row['class_id'];
        }

        $result1 = $conn->query("UPDATE user_account SET accountType = 1, school_id = '$userSchool', class_id = '$userClass' WHERE email = '$studentEmail';");
        if($result1 === true){
            echo "1";
        }else{
            echo "0";
        }
    }

    $conn->close();

?>