connect_error) {
header('Content-Type: application/json');
echo json_encode(array('response' => "Database connection error (".$conn->connect_error.")"));
exit;
}
if(isset($_POST["selectedschool"]) && $loggedin){
$_SESSION["selectedschool"] = $_POST["selectedschool"];
}
if(!isset($liteload) && !$loggedin && $isadmin){
header("Location: ".$curdir."login.php");
}else{
if($loggedin == true){
$id = $_SESSION["id"];
$sql = "SELECT * FROM `auth` WHERE `id` = '".$conn->real_escape_string($id)."'";
$result = $conn->query($sql);
if ($result == TRUE) {
if (!empty($result) && $result->num_rows > 0) {
$sqlvals = $result->fetch_assoc();
$username = $sqlvals["username"];
$type = $sqlvals["type"];
$connctdschids = explode(",", $sqlvals["connectedschoolids"]);
$sql = "SELECT * FROM `acctypes` WHERE `id` = '".$type."'";
mysqli_free_result($result);
$result = $conn->query($sql);
$sqlvals = $result->fetch_assoc();
$fulltype = $sqlvals["name_hun"];
}
}
mysqli_free_result($result);
if(isset($data_upload)){
if(isset($_POST["submit"])){
$modsql = "UPDATE `schools` SET `name` = '".$conn->real_escape_string($_POST['schoolname'])."', `type` = '".$conn->real_escape_string($_POST['schooltype'])."', `postalcode` = '".$conn->real_escape_string($_POST['postcode'])."', `spec` = '".str_replace(', ', ',', preg_replace('/\s+/', ' ', trim($conn->real_escape_string($_POST['spec']))))."', `location` = '".$conn->real_escape_string($_POST['loc'])."', `locationspec` = '".$conn->real_escape_string($_POST['locspec'])."', `phonenumber` = '".$conn->real_escape_string($_POST['phnnum'])."', `emailaddress` = '".$conn->real_escape_string($_POST['email'])."' WHERE `schools`.`id` = ".substr($_SESSION["selectedschool"], 1);
if ($conn->query($modsql) === TRUE) {
echo "Adat feltöltve";
} else {
echo "Error: " . $sql . "
" . $conn->error;
}
}
}
for($i = 0; $iquery($viewsql);
if ($result == TRUE) {
if(!isset($_SESSION["selectedschool"])) {
$_SESSION["selectedschool"] = "s".$connctdschids[$i];
}
if (empty($result) || $result->num_rows == 0) {
$modsql = "INSERT INTO `schools` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`, `email`) VALUES ('".$connctdschids[$i]."', '', '', '', '', '', '', '', '')";
$conn->query($modsql);
}
}
}
mysqli_free_result($result);
$viewsql = "SELECT * FROM `schools` WHERE `id` = ".substr($_SESSION["selectedschool"], 1);
$result = $conn->query($viewsql);
if ($result == TRUE) {
if (!empty($result) && $result->num_rows > 0) {
$selschvals = $result->fetch_assoc();
}
//else{
//$modsql = "INSERT INTO `schools` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`) VALUES ('".substr($_SESSION["selectedschool"], 1)."', '', '', '', '', '', '', '')";
//$conn->query($modsql);
//header("Refresh:0");
//}
}
mysqli_free_result($result);
}else{
$username = "Vendég";
$type = "0";
$sql = "SELECT * FROM `acctypes` WHERE `id` = '".$type."'";
mysqli_free_result($result);
$result = $conn->query($sql);
$sqlvals = $result->fetch_assoc();
$fulltype = $sqlvals["name_hun"];
}
?>
ParEdu Adminisztráció
close(); } ?>