-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.php
More file actions
104 lines (90 loc) · 4.68 KB
/
post.php
File metadata and controls
104 lines (90 loc) · 4.68 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
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
<?php require_once 'process.php'; ?>
<?php $con = new mysqli("localhost","root","","post"); ?>
<?php if(isset($_SESSION['message'])): ?>
<?php endif ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>post</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-dark bg-dark text-center">
<span class="navbar-brand mb-0 h1 text-center">post</span>
<div class="row" text-align="right">
<a href="logout.php"> Logout</a>
</div>
</nav>
<br><br><br>
<div class="container">
<div class="row">
<div class="col-md-4">
<h2 class="text-center">Add Post</h2>
<hr><br>
<form action="process.php" method="POST">
<div class="form-group">
<label for="postTitle">Post Title</label>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="text" name="post" class="form-control" id="postTitle" placeholder="Enter Post Title" required autocomplete="off" value="<?php echo $name; ?>">
</div>
<div class="form-group">
<label for="description">Description</label>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="text" name="description" class="form-control" id="description" placeholder="Enter description" required value="<?php echo $description; ?>">
</div>
<?php if($update == true): ?>
<button type="submit" name="update" class="btn btn-success btn-block">Update</button>
<?php else: ?>
<button type="submit" name="save" class="btn btn-primary btn-block">Save</button>
<?php endif; ?>
</form>
</div>
<div class="col-md-8">
<h2 class="text-center">Post</h2>
<hr>
<br><br>
<?php
if(isset($_SESSION['massage'])){
echo "<div class='alert alert-{$_SESSION['msg_type']} alert-dismissible fade show ' role='alert'>
<strong> {$_SESSION['massage']} </storng>
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>
";
}
?>
<?php
$result = mysqli_query($con, "SELECT * FROM post");
?>
<div class="row justify-content-center">
<table class="table">
<thead>
<tr>
<th>post Name</th>
<th>post description</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php
while($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['description']; ?></td>
<td>
<a href="post.php?edit=<?php echo $row['id']; ?>" class="btn btn-success">edit</a>
</td>
</tr>
<?php endwhile ?>
</table>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>