-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory_create.php
55 lines (40 loc) · 1.18 KB
/
category_create.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
<?php
include_once("includes/inc.global.php");
$p->site_section = LISTINGS;
$p->page_title = "Create a New Listing Category";
include("includes/inc.forms.php");
include_once("classes/class.category.php");
//
// Define form elements
//
$cUser->MustBeLevel(2);
$form->addElement("text", "category", "Category Description", array("size" => 30, "maxlength" => 30));
$form->addElement("static", null, null, null);
$form->addElement('submit', 'btnSubmit', 'Submit');
//
// Define form rules
//
$form->addRule('category', 'Enter the category description', 'required');
//
// Then check if we are processing a submission or just displaying the form
//
if ($form->validate()) { // Form is validated so processes the data
$form->freeze();
$form->process("process_data", false);
} else {
$p->DisplayPage($form->toHtml()); // just display the form
}
function process_data ($values) {
global $p, $cErr;
$category = new cCategory($values["category"]);
if ($category->SaveNewCategory()) {
$output = "The category has been created.";
} else {
$output = "Could not save the category. Please try again later.";
}
$p->DisplayPage($output);
}
//
// Form rule validation functions
//
?>