-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddCategory.php
More file actions
36 lines (29 loc) · 1021 Bytes
/
addCategory.php
File metadata and controls
36 lines (29 loc) · 1021 Bytes
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
<?php
require 'vendor/autoload.php';
use Parse\ParseObject;
use Parse\ParseUser;
use Parse\ParseException;
use Parse\ParseClient;
use Parse\ParseSessionStorage;
// Start the session
session_start();
$app_id = "kddcodGlyJ6DmGI7FihXt8BsXyOTS09Dgpj8UA49";
$rest_key = "ryU6g6D37JtDqIAnPbTq4SLNmihEIy8kSNPZxlhj";
$master_key = "Fm9X40ewplSIEDTOmYxVdCEN7ge31vgfFwScYr3y";
ParseClient::initialize( $app_id, $rest_key, $master_key );
if(isset($_POST["category"]) && $_POST["category"] != "" && strlen($_POST["category"]) <= 45) {
$category = new ParseObject("FAQ_Category");
$category->set("Text",$_POST["category"]);
try {
$category->save();
} catch (ParseException $ex) {
/* Should pass back a cookie with the error $ex->getMessage() */
setcookie("modError",$ex->getMessage());
}
}
else if(strlen($_POST["category"]) > 45) {
setcookie("modError","Category cannot contain more than 45 characters");
}
header("Location: index.php"); /* Redirect browser */
exit();
?>