connect_errno) { echo "Failed to connect to MySQL: (" . $conn->connect_errno . ") " . $conn->connect_error; } else { debug("Successful Connection"); // debug($conn->host_info); } if($conn->select_db('ps2020')) { debug("Using ps2020"); } else { error($conn->error); } $code = $_GET["q"]; $sql = "SELECT * FROM school"; $result = $conn->query($sql); if($result->num_rows > 0){ while($row = $result->fetch_assoc()) { //This is to check if code is for a teacher if($row["specific_teacherCode"] == $code){ $school_name = $row["school_name"]; echo "t-".$school_name; break; } } } $sql = "SELECT * FROM school_class"; $result = $conn->query($sql); if($result->num_rows > 0){ while($row = $result->fetch_assoc()) { //THis is to check if it is a student code if($row["specific_classCode"] == $code){ //So we have found an existing account //Username is already taken! $class_name = $row["class_name"]; echo "s-".$class_name; break; } } } //Username is available //But no class or school has been assigned echo "n"; $conn->close(); exit(); ?>