eventmanager/edit.php

103 lines
2.9 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['zalogowany']) || $_SESSION['perm']=='normal')
{
$_SESSION['blad_perm'] = '<span style="color:red">Brak uprawnien!</span>';
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);
$controller = $_SESSION['quantity_controller'];
$stopdate = $_SESSION['e_dtstp'];
if($_POST['title2'] == NULL )
{
$g1 = $_SESSION['e_title'];
}
else
{
$g1 = $_POST['title2'];
}
if($_POST['description2'] == NULL)
{
$g2 = $_SESSION['e_descr'];
}
else
{
$g2 = $_POST['description2'];
}
if($_POST['date_start2'] == NULL || ($_POST['date_start2'] >= $stopdate))
{
$g3 = $_SESSION['e_dtstr']; //domyślna poprzednia
}
elseif(($_POST['date_start2'] < $stopdate))
{
$g3 = $_POST['date_start2']; //nowa data
}
if($_POST['date_stop2'] == NULL || ($_POST['date_start2'] >= $_POST['date_stop2']))
{
$g4 = $_SESSION['e_dtstp'];
}
elseif(($_POST['date_start2'] < $_POST['date_stop2']))
{
$g4 = $_POST['date_stop2'];
}
if($_POST['time_start2'] == NULL || ($_POST['time_start2'] >= $_POST['time_stop2']))
{
$g5 = $_SESSION['e_tmstr'];
}
elseif(($_POST['time_start2'] < $_POST['time_stop2']))
{
$g5 = $_POST['time_start2'];
}
if($_POST['time_stop2'] == NULL || ($_POST['time_start2'] >= $_POST['time_stop2']))
{
$g6 = $_SESSION['e_tmstp'];
}
elseif(($_POST['time_start2'] < $_POST['time_stop2']))
{
$g6 = $_POST['time_stop2'];
}
if($_POST['location2'] == NULL)
{
$g7 = $_SESSION['e_loc'];
}
else
{
$g7 = $_POST['location2'];
}
if($_POST['quantity2'] == NULL || $controller > $_POST['quantity2'])
{
$g8 = $_SESSION['e_slots'];
}
elseif($controller <= $_POST['quantity2'])
{
$g8 = $_POST['quantity2'];
}
if($_POST['quantity_min2'] == NULL)
{
$g9 = $_SESSION['e_slots'];
}
else
{
$g9 = $_POST['quantity2_min'];
}
$zapytanietxt = "UPDATE `events` SET `title` = '".$g1."', `description` = '".$g2."', `date_start` = '".$g3."', `date_stop` = '".$g4."', `time_start` = '".$g5."', `time_stop` = '".$g6."', `location` = '".$g7."', `quantity` = '".$g8."', `quantity_min` = '".$g9."' WHERE `events`.`id_events` =".$_SESSION['id_eve'];
$rezultat = mysqli_query($polaczenie, $zapytanietxt);
$ile = mysqli_num_rows($rezultat);
header('Location: events.php');
unset($_SESSION['controller']);
?>