I'm creating a forum, for my site... And well... it doesn't exactly work...
Heres the code:
<?
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
include("../config.php");
$a = new database();
$a->connect();
if (!isset($_SESSION['user'])) {
print "You must be logged in, in order to access this area.";
print "<meta http-equiv=\"refresh\" content=\"3;URL=../index.php\">";
}
else {
//check for required fields from the form
if (!isset($_POST['id'])) {
print "This field MUST be filled in, go back to the forum and click 'New Topic' again.";
print "<meta http-equiv=\"refresh\" content=\"3;URL=../newtopic.php\">";
exit;
}
if (!isset($_POST['title'])) {
print "You can't make a post without a title, please go back and create one";
print "<meta http-equiv=\"refresh\" content=\"3;URL=../newtopic.php\">";
}
if (!isset($_POST['text'])) {
print "You can't make a post without a message, please go back and create one";
print "<meta http-equiv=\"refresh\" content=\"3;URL=../newtopic.php\">";
}
?>
<html>
<head>
<title>Posting Topic</title>
<body bgcolor="#504533" text="#ffffff" link="#ffffff" vlink="#ffffff" alink="#ffffff">
</head>
<body>
<?
$user = $_SESSION['user'];
$getname = mysql_query("SELECT * FROM login WHERE user='$user'");
while ($namer = mysql_fetch_array($getname, MYSQL_ASSOC)){
$postid2 = mysql_query("SELECT * FROM fmessages WHERE message='".$_POST['title']."'");
while ($postid = mysql_fetch_array($postid2, MYSQL_ASSOC)) {
$posterid = $postid['msg_id'];
$postedid = $postid['member_id'];
$add_post = "INSERT INTO fmessages (msg_date
, title, message, forum_id, member_id, stick
y, locked, type) VALUES ('".time()."', '".$_POST['
title']."', '".$_POST['text'].
"', '".$_POST['id']."', '".$namer['id']."
', '".$_POST['sticky']."', '".$
_POST['locked']."', '".$_POST['type']."')";
mysql_query($add_post) or die(mysql_error());
$useron = $_SESSION['user'];
mysql_query("UPDATE login SET posts=posts+1 WHERE user='$useron'");
mysql_query("UPDATE f
forums WHERE id='".$_POST['id']."' SET pos
ts=posts+1, topics=topics+1, lastpos
t='$posterid', lastpostname='$postedid'");
print "Your topic has been created.";
print "<meta http-equiv=\"refresh\
" content=\"1;URL=viewforum
.php?id=".$_POST['id']."\">";
}
}
}
?>
</body>
</html>
<?
?>
Whenever I change
$postid2 = mysql_query("SELECT * FROM f
messages WHERE message='".$_POST['title']."'");
while ($postid = mysql_fetch_array($postid2,
_ASSOC)) {
$posterid = $postid['msg_id'];
$postedid = $postid['member_id'];
"$postid2 = mysql_query("SELECT * FROM fme
ssages WHERE message='".$POST['title']."'");"
to a non-existant $POST ... it works... but whenever it uses an existing $_POST, it won't work... Its freakin me ou
t
Edit: Please note that I chopped up the first PHP tags so that it wouldn't make everything on the page screwy.