-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditPost.php
More file actions
64 lines (58 loc) · 2.11 KB
/
editPost.php
File metadata and controls
64 lines (58 loc) · 2.11 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
<?php require_once 'inc/connection.php' ?>
<?php
if(! isset($_SESSION['user_id']))
header("location:../login.php");
?>
<?php require_once 'inc/header.php' ?>
<!-- Page Content -->
<div class="page-heading products-heading header-text">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="text-content">
<h4>Edit Post</h4>
<h2>edit your personal post</h2>
</div>
</div>
</div>
</div>
</div>
<?php
if(isset($_GET['id'])){
$id = $_GET['id'];
$query = "select * from posts where posts.id=$id";
$runQuery = mysqli_query($conn , $query);
if(mysqli_num_rows($runQuery) ==1 ){
$post= mysqli_fetch_assoc($runQuery);
}else{
$_SESSION['errors'] = ["post not founded"];
header("location:index.php");
}
}else{
$_SESSION['errors'] = ["post not founded"];
header("location:index.php");
}
?>
<div class="container w-50 ">
<div class="d-flex justify-content-center">
<h3 class="my-5">edit Post</h3>
</div>
<?php require_once 'inc/error.php' ?>
<form method="POST" action="handle/update.php?id=<?php echo $id ?>" enctype="multipart/form-data">
<div class="mb-3">
<label for="title" class="form-label">Title</label>
<input type="text" class="form-control" id="title" name="title" value="<?php echo $post['title'] ?>">
</div>
<div class="mb-3">
<label for="body" class="form-label">Body</label>
<textarea class="form-control" id="body" name="body" rows="5"><?php echo $post['body'] ?></textarea>
</div>
<div class="mb-3">
<label for="body" class="form-label">image</label>
<input type="file" class="form-control-file" id="image" name="image" >
</div>
<img src="upload/<?php echo $post['image'] ?>" alt="" width="100px" srcset="">
<button type="submit" class="btn btn-primary" name="submit">Submit</button>
</form>
</div>
<?php require_once 'inc/footer.php' ?>