this is my create_topic.php
Code: Select all
<?php session_start(); ?>
<?php
if ((!isset($_SESSION['uid'])) || ($_GET['cid'] == "")) {
header("Location: index.php");
exit();
}
$cid = $_GET['cid'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create Forum Topic</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
<!--
h2 {
font-size: 36px;
color: #6F0000;
}
body,td,th {
font-size: 18px;
color: #6F0000;
background-attachment: fixed;
background-image: url(assets/image2.jpg);
background-repeat: no-repeat;
background-position: 27px 30px;
}
-->
</style></head>
<body>
<div id="wrapper">
<center><h2>Treston Forum Boards
</h2>
</center>
<?php
echo "<p>You are logged is as ".$_SESSION['username']." • <a href='logout_parse.php'>Logout</a>";
?>
<hr />
<div id="content">
<form action="create_topic_parse.php" method="post">
<p>Topic Title</p>
<input type="text" name="topic_title" size="98" maxlength="150" />
<p>Topic Content</p>
<textarea name="topic_content" rows="5" cols="75"></textarea>
<br /><br />
<input type="hidden" name="cid" value="<?php echo $cid; ?>" />
<input type="submit" name="topic_submit" value="Create Your Topic" />
</form>
</div>
</div>
</body>
</html>this is my create_topic_parse.php
Code: Select all
<?php
session_start();
if ($_SESSION['uid'] == "") {
header("Location: index.php");
exit();
}
if (isset($_POST['topic_submit'])) {
if (($_POST['topic_title'] == "") && ($_POST['topic_content'] == "")) {
echo "You did not fill in both fields. Please return to the previous page.";
exit();
} else {
include_once("connect.php");
$cid = $_POST['cid'];
$title = $_POST['topic_title'];
$content = $_POST['topic_content'];
$creator = $_SESSION['uid'];
$sql = "INSERT INTO topics (category_id, topic_title, topic_creator, topic_date, topic_reply_date) VALUES ('".$cid."', '".$title."', '".$creator."', now(), now())";
$res = mysql_query($sql) or die(mysql_error());
$new_topic_id = mysql_insert_id();
$sql2 = "INSERT INTO posts (category_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$new_topic_id."', '".$creator."', '".$content."', now())";
$res2 = mysql_query($sql2) or die(mysql_error());
$sql3 = "UPDATE categories SET last_post_date=now(), last_user_posted='".$creator."' WHERE id='".$cid."' LIMIT 1";
$res3 = mysql_query($sql3) or die(mysql_error());
if (($res) && ($res2) && ($res3)) {
header("Location: view_topic.php?cid=".$cid."&tid=".$new_topic_id);
} else {
echo "There was a problem creating your topic. Please try again.";
}
}
}
?>this is my post_reply.php
Code: Select all
<?php session_start(); ?>
<?php
if ((!isset($_SESSION['uid'])) || ($_GET['cid'] == "")) {
header("Location: index.php");
exit();
}
$cid = $_GET['cid'];
$tid = $_GET['tid'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Forum Series - Post Forum Reply</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="wrapper">
<h2>TimKippTutorials | Forum Tutorial Series - Part 5</h2>
<p>Posting Replies</p>
<?php
echo "<p>You are logged is as ".$_SESSION['username']." • <a href='logout_parse.php'>Logout</a>";
?>
<hr />
<div id="content">
<form action="post_reply_parse.php" method="post">
<p>Reply Content</p>
<textarea name="reply_content" rows="5" cols="75"></textarea>
<br /><br />
<input type="hidden" name="cid" value="<?php echo $cid; ?>" />
<input type="hidden" name="tid" value="<?php echo $tid; ?>" />
<input type="submit" name="reply_submit" value="Post Your Reply" />
</form>
</div>
</div>
</body>
</html>
Code: Select all
<?php
session_start();
if ($_SESSION['uid']) {
if (isset($_POST['reply_submit'])) {
include_once("connect.php");
$creator = $_SESSION['uid'];
$cid = $_POST['cid'];
$tid = $_POST['tid'];
$reply_content = $_POST['reply_content'];
$sql = "INSERT INTO posts (category_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$tid."', '".$creator."', '".$reply_content."', now())";
$res = mysql_query($sql) or die(mysql_error());
$sql2 = "UPDATE categories SET last_post_date=now(), last_user_posted='".$creator."' WHERE id='".$cid."' LIMIT 1";
$res2 = mysql_query($sql2) or die(mysql_error());
$sql3 = "UPDATE topics SET topic_reply_date=now(), topic_last_user='".$creator."' WHERE id='".$tid."' LIMIT 1";
$res3 = mysql_query($sql3) or die(mysql_error());
// Email Sending
if (($res) && ($res2) && ($res3)) {
echo "<p>Your reply has been successfully posted. <a href='view_topic.php?cid=".$cid."&tid=".$tid."'>Click here to return to the topic.</a></p>";
} else {
echo "<p>There was a problem posting your reply. Try again later.</p>";
}
} else {
exit();
}
} else {
exit();
}
?>
