58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
if(!isset($_SESSION)) session_start();
|
||
|
|
|
||
|
|
|
||
|
|
include('/home/giers/Web/db_settings.php'); //declares $db_server, $db_password and $db_password
|
||
|
|
$db_name = 'hori';
|
||
|
|
$db = mysqli_connect($db_server, $db_user, $db_password, $db_name);
|
||
|
|
mysqli_set_charset($db, "utf8");
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if (isset($_POST['name']) && isset($_POST['loc']) && isset($_POST['typ'])){
|
||
|
|
$typNo = 0;
|
||
|
|
if ($_POST['typ'] == 'galerie') { $typNo = 1; }
|
||
|
|
if ($_POST['typ'] == 'akademie') { $typNo = 2; }
|
||
|
|
if ($_POST['typ'] == 'venue') { $typNo = 3; }
|
||
|
|
if ($_POST['typ'] == 'stiftung') { $typNo = 4; }
|
||
|
|
if ($_POST['typ'] == 'festival') { $typNo = 5; }
|
||
|
|
if ($_POST['typ'] == 'kunstler') { $typNo = 6; }
|
||
|
|
$query = "INSERT INTO `institut`(`name`, `location`, `facebook`, `twitter`, `instagram`, `web`, `typ`) VALUES (\"".$_POST['name']."\",\"".$_POST['loc']."\",\"".$_POST['fb']."\",\"".$_POST['twitter']."\",\"".$_POST['insta']."\",\"".$_POST['web']."\",".$typNo.");";
|
||
|
|
//echo("<script>console.log('".$query."');</script>");
|
||
|
|
mysqli_query($db, $query);
|
||
|
|
//header("location: #");
|
||
|
|
}
|
||
|
|
|
||
|
|
if (isset($_GET['delete'])){
|
||
|
|
$query = "DELETE FROM `institut` WHERE `institut`.`id` = " . $_GET['delete'] . ";";
|
||
|
|
mysqli_query($db, $query);
|
||
|
|
//echo $_GET['delete'];
|
||
|
|
header("location: ../index.php");
|
||
|
|
}
|
||
|
|
|
||
|
|
function fetch_object($db, $query){
|
||
|
|
$result = mysqli_query($db, $query);
|
||
|
|
return mysqli_fetch_object($result);
|
||
|
|
}
|
||
|
|
function fetch_all($db, $query){
|
||
|
|
$result = mysqli_query($db, $query);
|
||
|
|
return mysqli_fetch_all($result);
|
||
|
|
}
|
||
|
|
function clean_url($url){
|
||
|
|
if (0 !== strpos($url, 'http://') && 0 !== strpos($url, 'https://')) {
|
||
|
|
return "http://{$url}";
|
||
|
|
} else { return $url; }
|
||
|
|
}
|
||
|
|
function nullOrColon($str){
|
||
|
|
return !empty($str) ? "'".$str."'" : "NULL";
|
||
|
|
}
|
||
|
|
function nullOrInt($int){
|
||
|
|
return !empty($int) ? $int : "NULL";
|
||
|
|
}
|
||
|
|
function nullOrTrue($bool){
|
||
|
|
return !empty($bool) ? "TRUE" : "NULL";
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|