-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit.php
106 lines (61 loc) · 2.09 KB
/
edit.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
<?php
session_start();
error_reporting(0);
if($_SESSION['email']==true){
}else{
header('location:admin_login.php');
}
$page='category';
include('include/header.php');
?>
<?php
include('db/connection.php');
$id = $_GET['id'];
$query = mysqli_query($conn,"SELECT * FROM category WHERE id = '$id' ");
while($row = mysqli_fetch_array($query)){
$category = $row['category_name'];
$des =$row['des'];
}
?>
<div style=" width:70%;margin-left: 25%; margin-top: 10%">
<form action="" name="categoryform" method="post" onsubmit="return validateform()">
<h1>Update Category</h1><hr>
<div class="form-group">
<label for="email">Category:</label>
<input type="text" name="category1" class="form-control" value="<?php echo $category; ?>" id="email">
</div>
<div class="form-group">
<label for="comment">Description:</label>
<textarea class="form-control" name="des1" rows="5" id="comment"><?php echo $des; ?></textarea>
</div>
<input type="hidden" name="id" value="<?php echo $_GET['id'];?>">
<input type="submit" name="submit1" class="btn btn-primary" value="Update category">
</form>
<script>
function validateform(){
var x = document.forms['categoryform']['category'].value;
if(x==""){
alert('Category must be filled out !');
return false;
}
}
</script>
</div>
<?php
include('db/connection.php');
if(isset($_POST['submit1'])){
$id = $_POST['id'];
$category = $_POST['category1'];
$des = $_POST['des1'];
$query1 = mysqli_query($conn,"UPDATE category SET category_name = '$category',des = '$des' WHERE id = '$id'");
if($query1){
echo "<script>alert('Category Updated Sucessfuly')</script>";
echo "<script>window.location='http://localhost/news/category.php';</script>";
}else{
echo "Category is not Updated";
}
}
?>
<?php
include('include/footer.php');
?>