-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
101 lines (90 loc) · 3.62 KB
/
profile.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Сокольская Е.К. </title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel=”stylesheet” href=”https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css” />
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container nav_bar">
<div class="row">
<div class="col-3 nav_logo"></div>
<div class="col-9">
<div class="nav_text"> Информация обо мне </div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-12">
<h1> Немного о себе: </h1>
</div>
</div>
<div class="row">
<div class="col-8">
<h2> Меня зовут Катя, я из Геленджика. Люблю Кипелова!</h2>
</div>
<div class="col-4">
<div class="my_photo"></div>
<div class="title_photo"> Валерий Кипелов </div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="button_js col-12">
<button id="myButton"> click me </button>
<p id="demo"></p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-12">
<h1 class="hello">
Привет, <?php echo $_COOKIE['User']; ?>
</h1>
</div>
<div class="col-12">
<form class="form_align" method="POST" action="profile.php" enctype="multipart/form-data" name="upload">
<input type="text" class="form" type="text" name="title" placeholder="Заголовок">
<textarea name="text" cols="30" rows="10" placeholder="Введите текст..."></textarea>
<input type="file" name="file" /><br>
<button type="submit" class="btn_red" name="submit">Сохранить пост</button>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="js/button.js"></script>
</body>
</html>
<?php
require_once('bd.php');
$link = mysqli_connect('127.0.0.1', 'root', '1', 'first');
if (isset($_POST['submit'])) {
$title = $_POST['title'];
$main_text = $_POST['text'];
if (!$title || !$main_text) die ("Заполните все поля");
$sql = "INSERT INTO posts (title, main_text) VALUES ('$title', '$main_text')";
if(!empty($_FILES["file"]))
{
if (((@$_FILES["file"]["type"] == "image/gif") || (@$_FILES["file"]["type"] == "image/jpeg")
|| (@$_FILES["file"]["type"] == "image/jpg") || (@$_FILES["file"]["type"] == "image/pjpeg")
|| (@$_FILES["file"]["type"] == "image/x-png") || (@$_FILES["file"]["type"] == "image/png"))
&& (@$_FILES["file"]["size"] < 102400))
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
echo "Load in: " . "upload/" . $_FILES["file"]["name"];
}
else
{
echo "upload failed!";
}
}
if (!mysqli_query($link, $sql)) die ("Не удалось добавить пост");
}
?>