-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd_Category.php
More file actions
81 lines (76 loc) · 3.01 KB
/
Add_Category.php
File metadata and controls
81 lines (76 loc) · 3.01 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
<!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="style.css" />
<meta charset="utf-8" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<?php
include_once("connection.php");
if(isset($_POST["btnAdd"]))
{
$id = $_POST["txtID"];
$name = $_POST["txtName"];
$des = $_POST["txtDes"];
$err="";
if($id=="")
{
$err .="<li>Enter Category ID, please</li>";
}
if($name=="")
{
$err .="<li>Enter Category Name, please</li>";
}
if($err!="")
{
echo "<ul>$err</ul>";
}
else
{
$id =htmlspecialchars(pg_escape_string($conn,$id));
$name =htmlspecialchars(pg_escape_string($conn,$name));
$des =htmlspecialchars(pg_escape_string($conn,$des));
$sq="SELECT * FROM category where cat_id='$id' or cat_name='$name'";
$result = pg_query($conn,$sq);
if(pg_num_rows($result)==0)
{
pg_query($conn, "INSERT INTO category (cat_id, cat_name, cat_des) VALUES ('$id','$name','$des')");
echo '<meta http-equiv="Refresh" content="0; URL=?page=category_management"/>';
}
else
{
echo "<li>Duplicate category ID or Name</li>";
}
}
}
?>
<div class="container">
<h2>Adding Category</h2>
<form id="form1" name="form1" method="post" action="" class="form-horizontal" role="form">
<div class="form-group">
<label for="txtTen" class="col-sm-2 control-label">Category ID(*): </label>
<div class="col-sm-10">
<input type="text" name="txtID" id="txtID" class="form-control" placeholder="Catepgy ID"
value='<?php echo isset($_POST["txtID"])?($_POST["txtID"]):"";?>'>
</div>
</div>
<div class="form-group">
<label for="txtTen" class="col-sm-2 control-label">Category Name(*): </label>
<div class="col-sm-10">
<input type="text" name="txtName" id="txtName" class="form-control" placeholder="Catepgy Name"
value='<?php echo isset($_POST["txtName"])?($_POST["txtName"]):"";?>'>
</div>
</div>
<div class="form-group">
<label for="txtMoTa" class="col-sm-2 control-label">Description(*): </label>
<div class="col-sm-10">
<input type="text" name="txtDes" id="txtDes" class="form-control" placeholder="Description"
value='<?php echo isset($_POST["txtDes"])?($_POST["txtDes"]):"";?>'>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-primary" name="btnAdd" id="btnAdd" value="Add new" />
<input type="button" class="btn btn-primary" name="btnIgnore" id="btnIgnore" value="Ignore"
onclick="window.location='Category_Management.php'" />
</div>
</div>
</form>
</div>