Ok, here goes:
<?
function index() {
include("header.php");
require_once("mainfile.php");
echo "<table border=\"0\">";
$result = mysql_query("SELECT * FROM `forum` ORDER BY `secid` ASC") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$main_name = $row['main_name'];
$desc = $row['desc'];
$secid = $row['secid'];
echo "<tr><td width=\"1%\" height=\"1%\" class=\"tbcontent\"><img src=\"/sql/images/computer.gif\"></td><td> </td><td valign=\"top\" width=\"100%\" class=\"tbcontent\"><a href=\"/sql/forum.php?forum=show&secid=$secid\"><b>$main_name</b></a><br>$desc</td><td>$topics</td></tr><tr><td> </td></tr>";
}
echo "</table>";
include("footer.php");
}
function show() {
global $secid, $postid, $topic_name, $poster, $topic_msg;
include("header.php");
require_once("mainfile.php");
$i = "0";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"1%\"><tr><td width=\"10%\" class=\"tbcontent\"><b>Post #</b></td><td width=\"70%\" align=\"left\" class=\"tbcontent\"><b>Message Title</b></td><td width=\"20%\" class=\"tbcontent\"><b>Poster</b></td>";
$result = mysql_query("SELECT * FROM forum_topics WHERE secid='$secid' ORDER BY `id` DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$topic_name = $row['topic_name'];
$poster = $row['poster'];
$id = $row['id'];
$i++;
echo "<tr><td class=\"tbcontent\">$i</td><td valign=\"top\" class=\"tbcontent\"><a href=\"/sql/forum.php?forum=post&secid=$secid&id=$id\">$topic_name</a></td><td class=\"tbcontent\">$poster</td></tr>";
}
echo "</table><p><b>Why not post, and join the discussion??</b><br>
<form method=\"post\" action=\"/sql/forum.php?forum=post_topic\">
<input type=\"hidden\" name=\"postid\" value=\"$id\">
<input type=\"hidden\" name=\"secid\" value=\"$secid\">
Name:<br><input type=\"text\" name=\"poster\"><br>
Topic Name:<br><input type=\"text\" name=\"topic_name\"><br>
Message:<br><textarea name=\"topic_msg\" rows=\"7\" cols=\"60\"></textarea><br>
<input type=\"Submit\" name=\"Submit\" value=\"Submit\">
</form>";
include("footer.php");
}
function post() {
global $id, $secid;
include("header.php");
require_once("mainfile.php");
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"1%\">";
$result = mysql_query("SELECT * FROM `forum_post` WHERE id='$id' AND secid='$secid' ORDER BY `post_num` DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$msg = $row['msg'];
$name = $row['name'];
$msg_title = $row['msg_title'];
$newid = $row['id'] + 1;
echo "<b>$msg_title</b> - Written By $name<hr>$msg<p>";
}
echo "<tr><td width=\"100%\" height=\"1%\" border=\"0\"> <p><b>Why not post, and join the discussion??</b><br>
<form method=\"post\" action=\"/sql/forum.php?forum=post_reply\">
<input type=\"hidden\" name=\"id\" value=\"$id\">
<input type=\"hidden\" name=\"secid\" value=\"$secid\">
Name:<br><input type=\"text\" name=\"post_name\"><br>
Title:<br><input type=\"text\" name=\"post_title\"><br>
Message:<br><textarea name=\"post_msg\" rows=\"7\" cols=\"60\"></textarea><br>
<input type=\"Submit\" name=\"Submit\" value=\"Submit\">
</form><td></tr>";
echo "</table>";
include("footer.php");
}
function post_reply() {
global $post_name, $post_title, $post_msg, $secid, $id;
header("Location: /sql/forum.php?forum=post&secid=$secid&id=$id");
require_once("mainfile.php");
mysql_query("INSERT INTO `forum_post` ( `name` , `msg` , `msg_title` , `secid` , `id` )
VALUES ( '$post_name', '$post_msg', '$post_title', '$secid', '$id')") or die(mysql_error());
}
function post_topic() {
global $topic_name, $poster, $secid, $postid, $topic_msg;
require_once("mainfile.php");
mysql_query("INSERT INTO `forum_post` ( `name` , `msg` , `secid` , `id` , `msg_title` ) VALUES ( '$poster', '$topic_msg', '$secid', '$postid', '$topic_name')") or die(mysql_error());
mysql_query("INSERT INTO `forum_topics` ( `poster` , `topic_name` , `secid` , `id` ) VALUES ( '$poster', '$topic_name', '$secid', '$postid')") or die(mysql_error());
header("Location: /sql/forum.php?forum=show&secid=$secid");
}
switch($forum) {
default:
index();
break;
case "show":
show();
break;
case "post":
post();
break;
case "post_reply":
post_reply();
break;
case "post_topic":
post_topic();
break;
}
?>
Its the $id from show() thats not carrying to post_topic()