-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreateblog.php
More file actions
71 lines (57 loc) · 2.32 KB
/
createblog.php
File metadata and controls
71 lines (57 loc) · 2.32 KB
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
<?php
session_start();
require_once('inc/header.php') ;
require_once('inc/nav2.php') ;
?>
<br><br><br><br>
<?php
if(isset($_POST['blogcreate'])){
$blogauthor=$_POST['blogauthor'];
$blogtitle=$_POST['blogtitle'];
$blogcategory=$_POST['blogcategory'];
$blogsummary=$_POST['blogsummary'];
$blogcontent=$_POST['blogcontent'];
$blogimage=$_POST['blogimage'];
// $cquery="INSERT INTO posts('title','author','content','category','summary','date','image') VALUES('{$blogtitle}','{$blogauthor}','{$blogcontent}','{$blogcategory}','{$blogsummary}',now(),'{$blogimage}')";
$cquery="INSERT INTO `posts` (`id`, `title`, `image`, `author`, `content`, `category`, `summary`, `date`) VALUES (NULL, '$blogtitle', '$blogimage', '$blogauthor', '$blogcontent', '$blogcategory', '$blogsummary', CURRENT_TIMESTAMP)" ;
$cresult=mysqli_query($conn,$cquery);
if($cresult){
header("location: blog.php");
}
}
?>
<div class="container">
<h1>Create Blog Here:</h1>
<form method="post">
<div class="form-group">
<label for="blogauthor">Blog Author:</label>
<input type="text" name="blogauthor" class="form-control" placeholder="author" required>
</div>
<div class="form-group">
<label for="blogtitle">Blog Title:</label>
<input type="text" name="blogtitle" class="form-control" placeholder="title" required>
</div>
<div class="form-group">
<label for="blogcategory">Blog Category:</label>
<input type="text" class="form-control" name="blogcategory" placeholder="Eg.c++,PHP,javascript." required>
</div>
<div class="form-group">
<label for="blogsummary">Blog Summary:</label>
<textarea class="form-control" name="blogsummary" rows="2" placeholder="Enter Summary here" required></textarea>
</div>
<div class="form-group">
<label for="blogcontent">Blog Content:</label>
<textarea class="form-control" name="blogcontent" rows="5" placeholder="Enter Content here" required></textarea>
</div>
<div class="form-group">
<label for="blogimage">Image:</label>
<input type="text" name="blogimage" class="form-control" placeholder="image in img directory">
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Create" name="blogcreate">
</div>
</form>
</div>
<?php
require_once('inc/footer.php') ;
?>