-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddCategory.php
59 lines (58 loc) · 1.36 KB
/
addCategory.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
<?php
include("dbconnect.php");
if($_POST['submitted'])
{
$category = $_POST['category'];
if (mysql_query('INSERT INTO category(category) values ("'.$category.'");', $connection))
{
print '<div class="success">Category successfully added</div>';
}
else
{
$error = mysql_error();
print '<div class="error">'.$error."</div><br>";
$size = strlen($error);
}
mysql_close($connection);
}
?>
<html>
<style type="text/css">
input.submit
{
position:relative;
display:inline;
}
div.success
{
background-color:#009911;
border: 5px solid #001199;
color:#FFFFFF;
overflow:auto;
width:<?php if($size){print $size;} else{print '300px';} ?>;
}
div.error
{
background-color:#990000;
color:#000000;
border: 5px dashed #000000;
width:<?php if($size){$size=($size *6)+10; print $size.'px';} else{print '300px';} ?>;
}
</style>
<head>
<title>Add Category</title>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<label for="category">Category Name</label>
<input type="text" name="category" size="20">
<input type="hidden" name="submitted" value="1">
<br />
<br />
<input class="submit" type="submit" value="Submit">
</form>
<form action="edit.php">
<input type="submit" value="Back">
</form>
</body>
</html>