-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_new_gallery.php
50 lines (50 loc) · 1.92 KB
/
create_new_gallery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Добавление новой галлереи</title>
<meta charset='utf-8'>
<link rel="stylesheet" href="../Style/gallery_stylesheet.css">
</head>
<body>
<?php
require_once("connect_db.php");
if (!isset($_REQUEST['SubAction2']))
{
?>
<form id="AddNewGallery" action = "<?=$_SERVER['SCRIPT_NAME']?>" method="post">
<h2>Введите имя и путь для иконки новой галлереи:</h2><br />
<p>Имя:<input type="text" name="title" value="" form="AddNewGallery"></p>
<p>Иконка:<input type="text" name="path" value="" form="AddNewGallery" placeholder="Вводите путь используя '/'"></p>
<input type="submit" name="SubAction2" value="Add" form="AddNewGallery">
<input type="submit" name="SubAction2" value="Cancel" form="AddNewGallery" >
</form>
<?php
}
else
{
switch($_REQUEST['SubAction2'])
{
case 'Add':
$data = date("y.m.d");
$title = $_REQUEST['title'];
$path = $_REQUEST['path'];
$query = "INSERT INTO galleries VALUE (NULL, '$title', '$path', '$data')";
$pdo->exec($query);
$query = "SELECT id FROM galleries WHERE title='$title'";
$gallery_id = $pdo->query($query);
$gallery_id = $gallery_id->fetchAll(PDO::FETCH_ASSOC);//то же самое, колхозное извлечение нужного мне значения из многомерного массива
$gallery_id = $gallery_id['0'];
$gallery_id = $gallery_id['id'];
$dir = dirname($_SERVER['SCRIPT_NAME']);
if ($dir=='\\') $dir='';
header("Location: $dir/gallery_content.php?gallery_id=$gallery_id");
break;
case "Cancel":
$dir = dirname($_SERVER['SCRIPT_NAME']);
if ($dir=='\\') $dir='';
header("Location: $dir/galleries_list.php");
}
}
?>
</body>
</html>