-
Notifications
You must be signed in to change notification settings - Fork 154
/
create-blog.php
129 lines (95 loc) · 5.4 KB
/
create-blog.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
session_start();
define('TITLE',"Create Blog | KLiK");
if(!isset($_SESSION['userId']))
{
header("Location: login.php");
exit();
}
include 'includes/HTML-head.php';
?>
<link rel="stylesheet" type="text/css" href="css/comp-creation.css">
</head>
<body>
<?php include 'includes/navbar.php'; ?>
<div class="bg-contact2" style="background-image: url('img/black-bg.jpg');">
<div class="container-contact2">
<div class="wrap-contact2">
<form class="contact2-form" action="includes/create-blog.inc.php" method='post'
enctype="multipart/form-data">
<label class="btn btn-primary position-absolute mt-2 ml-2">
Change Cover Image <input type="file" id="imgInp" name='dp' hidden>
</label>
<img class="cover-img " id="blah" src="#">
<br><br><br>
<span class="contact2-form-title">
Create a Blog
</span>
<span class="text-center">
<?php
if(isset($_GET['error']))
{
if($_GET['error'] == 'emptyfields')
{
echo '<h5 class="text-danger">*Fill In All The Fields</h5>';
}
else if ($_GET['error'] == 'catnametaken')
{
echo '<h5 class="text-danger">*A category with the given name already exists</h5>';
}
else if ($_GET['error'] == 'sqlerror')
{
echo '<h5 class="text-danger">*Website Error: Contact admin to have the issue fixed</h5>';
}
}
else if (isset($_GET['catcreation']) == 'success')
{
echo '<h5 class="text-success">*Category successfully created</h5>';
}
?>
</span>
<div class="wrap-input2 validate-input" data-validate="Name is required">
<input class="input2" type="text" id="title" name="btitle">
<span class="focus-input2" data-placeholder="Blog Title"></span>
</div>
<div class="wrap-input2 validate-input" data-validate = "Description is required">
<textarea class="input2" id="content" name="bcontent"rows="20"></textarea>
<span class="focus-input2" data-placeholder="Blog Content"></span>
</div>
<div class="container-contact2-form-btn">
<div class="wrap-contact2-form-btn">
<div class="contact2-form-bgbtn"></div>
<button class="contact2-form-btn" type="submit" name="create-blog-submit">
Create Blog
</button>
</div>
</div>
<div class="text-center">
<br><br><a class="btn btn-light btn-lg btn-block" href="blogs.php">
View All Blogs</a>
</div>
</form>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/creation-main.js"></script>
<script>
var dp = 'img/blog-cover.png';
$('#blah').attr('src', dp);
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function() {
readURL(this);
});
</script>
</body>
</html>