PDO::ERRMODE_EXCEPTION )); }catch (Exception $e){ die("Error : ".$e->getMessage()); } $req = $db->prepare('INSERT INTO `categories` (cat_name, cat_description) VALUES (:cat_name, :cat_description)'); $req->execute(array( "cat_name"=>$name, "cat_description"=>$description )); } ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); session_start(); $_SESSION['error_msg'] = ""; if (isset($_POST['submit'])) { if (isset($_SESSION['username'])) { if (isset($_POST['title'])) { $name = $_POST['title']; } else { $_SESSION['error_msg'] .= "You did not enter a proper category title. \n"; } if (isset($_POST['description'])) { $description = $_POST['description']; } else { $_SESSION['error_msg'] .= "You did not enter a proper category description. \n"; } } else { $_SESSION['error_msg'] .= "You did not log in.\n"; header('Location: '."/auth/login/"); } } else { $_SESSION['error_msg'] .= "You did not sumit the category creation form.\n"; } if ($_SESSION['error_msg'] == "") { create_category($name, $description); header('Location: '."/forum"); } else { header('Location: '."/auth/login/"); } ?>