chiro-canto/public/forum/newtopic.php

56 lines
1.8 KiB
PHP

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
require "$root/database/credentials.php";
// Connect the database
try{
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
$user,
$password,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
}catch (Exception $e){
die("Error : ".$e->getMessage());
}
$req = $db->prepare('SELECT cat_name, cat_description FROM `categories` WHERE id=:id');
$req->execute(array(
"id"=>$_GET['cat']
));
if ($data = $req->fetch())
{
$cat_name = $data['cat_name'];
$cat_description = $data['cat_description'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chiro - Canto</title>
<link rel="stylesheet" type="text/css" href="/styles/style.css">
</head>
<body>
<?php include("$root/menu.php");?>
<?php include("$root/header.php");?>
<section>
<h2>Forum</h2>
<h3>Create a new topic <?=isset($cat_name) ? "in ".$cat_name : ""?></h3>
<form action="createtopic.php" method="post">
<label for="topic">Topic subject</label>
<input type="text" name="topic_subject" id="topic" placeholder="Enter a topic subject.." required>
<label for="category">Topic category</label>
<input type="number" id="category" name="category" value="<?=$_GET['cat']?>" required>
<input type="submit" value="submit" name="submit"><input type="reset" value="reset">
</form>
</section>
<?php include("$root/footer.php");?>
</body>
<script src="/scripts/script.js"></script>
</html>