public function create() { global $database; if (!empty($_POST['topic']) && !empty($_POST['content'])) { $article = new RJ_News(); $val = new Val(); $error = ""; if ($val->maxlength($_POST['topic'], 500)) { $article->news_topic = htmlspecialchars($_POST['topic']); } else { $error .= "Topic Incorrect, "; } $article->news_content = htmlspecialchars($_POST['content']); $article->news_visible = $_POST['visible']; if (!empty($_FILES['image']['name'])) { $result = $this->upload; if ($result) { $article->news_image = $result; } else { $error .= "Image Incorrect"; } } if ($error == "") { if ($article->create()) { $_SESSION['adminmessage'] = "News successfully created"; return true; } else { $_SESSION['adminmessage'] = "An error occured while connecting with database, please try again"; return false; } } else { $_SESSION['adminmessage'] = $error; return false; } } else { return false; } }