eventmanager/leave.php

73 lines
2.6 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['zalogowany']))
{
header('Location: index.php');
exit();
}
ini_set("display_errors", 0);
require_once "dbconnect.php";
$polaczenie = mysqli_connect($host, $db_user, $db_password);
mysqli_query($polaczenie, "SET CHARSET utf8");
mysqli_query($polaczenie, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
mysqli_select_db($polaczenie, $db_name);
$zapytanietxt = "SELECT manager.employeeID, events.id_events, events.slots FROM manager, events WHERE events.id_events = manager.id_events AND manager.id_events = '".$_SESSION['id_eve']."'";
$rezultat = mysqli_query($polaczenie, $zapytanietxt);
$ile = mysqli_num_rows($rezultat);
$a1 = $_SESSION['e_slots'];
require_once "dbconnect.php";
$polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
if ($polaczenie->connect_errno!=0)
{
echo "Error: ".$polaczenie->connect_errno;
}
else
{
#$login = $_SESSION['employeeID'];
$login = htmlentities($login, ENT_QUOTES, "UTF-8");
if ($rezultat = @$polaczenie->query(
sprintf("SELECT manager.employeeID, events.id_events FROM manager, events WHERE events.id_events = manager.id_events AND manager.id_events = '".$_SESSION['id_eve']."' AND manager.employeeID='".$_SESSION['employeeID']."'",
mysqli_real_escape_string($polaczenie,$login))))
{
$ilu_userow = $rezultat->num_rows;
if($ilu_userow>0)
{
ini_set("display_errors", 0);
require_once "dbconnect.php";
$polaczenie = mysqli_connect($host, $db_user, $db_password);
mysqli_query($polaczenie, "SET CHARSET utf8");
mysqli_query($polaczenie, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
mysqli_select_db($polaczenie, $db_name);
$zapytanietxt = "DELETE FROM manager WHERE manager.employeeID ='".$_SESSION['employeeID']."' AND manager.id_events ='".$_SESSION['id_eve']."'";
$rezultat = mysqli_query($polaczenie, $zapytanietxt);
#$ile = mysqli_num_rows($rezultat);
header('Location: events.php');
}
else
{
$wiersz = $rezultat->fetch_assoc();
$_SESSION['id_log'] = "Jeszcze nie dołączyłeś do eventu!";
unset($_SESSION['blad']);
$rezultat->free_result();
header('Location: events.php');
}
}
}
unset($_SESSION['controller']);
?>