I own a mafia game site and i have a little problem with a script, if anyone could take a quick look it would be great.
<?
session_start();
if (!(isset($_SESSION["real_name"])))
{
//echo "I'm not logged in";
header('Location: login.php');
}
else
{
echo "";
}
?>
<html>
<head>
<title>Lock-N-Load :: View Topic</title></head>
<link REL="stylesheet" TYPE="text/css" HREF="main.css">
<script language=javascript src=Menus.js></script>
<body background="wallpaper.jpg">
<center>
<table border="0" cellspacing="0" cellpadding="0" align="center" width="95%" class="cat">
<TR>
<TD width="150" background="tdbg3.jpg" bgcolor="#222222" valign="top">
<?php include("leftmenu.php");?>
</TD>
<td width="100%" valign="top"> <br>
<?php
include "bb.php";
include "includes/db_connect.php";
// get value of id that sent from address bar
$id=$_GET['id'];
$username=$_SESSION["real_name"];
$tbl_name="forum_answer";
if ($_POST['Submit']){
$sql5="SELECT * FROM forum_question WHERE id='$id'";
$result5=mysql_query($sql5);
while($rows5=mysql_fetch_array($result5)){
$locked = $rows5['locked'];
}
if ($locked == 1 && $userlevel <5){
echo "<font color=red><b>Sorry but this topic is locked!</b></font><br><br>";
}else{
if ($mute == 1){
echo "<font color=red><b>You have been muted!</b></font><br><br>";
}else{
if ($mute==0){
// Find highest answer number.
$sql="SELECT MAX(a_id) AS Maxa_id FROM $tbl_name WHERE question_id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
// add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1
if ($rows) {
$Max_id = $rows['Maxa_id']+1;
}
else {
$Max_id = 1;
}
// get values that sent from form
$username=$_SESSION["real_name"];
$a_answer=$rows['a_answer'];
$datetime = gmdate('Y-m-d h:i:s');
// Insert answer
$sql2="INSERT INTO `forum_answer` (`question_id`, `a_id`, `username`, `a_answer`, `a_datetime`, `place`)VALUES('$id', '$Max_id', '$username', '$a_answer', '$datetime', '$crew')";
$result2=mysql_query($sql2);
if($result2){
// If added new answer, add value +1 in reply column
$tbl_name2="forum_question";
$sql3="UPDATE $tbl_name2 SET reply='$Max_id', lastreply='$time' WHERE id='$id'";
$result3=mysql_query($sql3);
}
else {
echo "ERROR";
}}
///END///
}}
}
$sql="SELECT * FROM forum_question WHERE id='$id'";
$result=mysql_query($sql);
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
$rows=mysql_fetch_array($result);
$title = $rows['username']
?>
<table border=1 align="center" cellspacing=0 cellpadding=2 width=75% bordercolor=black class=sub2>
<tr>
<td class=header><b><? echo dobbcodes($rows['title']); ?></b> - <a href="viewprofile.php?viewuser=<? echo $rows['username']; ?>"><? echo $rows['username']; ?></a>
</td>
</tr>
<tr>
<td><? echo dobbcodes($rows['content']);?>
</td>
</tr>
</table>
<br>
<?php
$tbl_name2="forum_answer"; // Switch to table "forum_answer"
$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id' ORDER BY a_id DESC";
$result2=mysql_query($sql2);
while($rows=mysql_fetch_array($result2)){
$id2=$rows['a_id'];
$kk=$rows['username'];
$sql= mysql_query("SELECT * FROM users WHERE username='$kk' LIMIT 1");
$i = mysql_fetch_object($sql);
if($i->userlevel=="20"){
$echo = "<font color=red><b>$i->username</b></font>";
}elseif ($i->userlevel=="10"){
$echo = "<font color=blue><b>$i->username</b></font>";
}elseif ($i->userlevel=="5"){
$echo = "<font color=yellow><b>$i->username</b></font>";
}else{
$echo = "$i->username";
}
?>
<br>
<table border=1 align="center" cellspacing=0 cellpadding=2 width=75% bordercolor=black class=sub>
<tr>
<td class=sub2><a href="viewprofile.php?viewuser=<? echo $rows['username']; ?>"><b><? echo "<a class=usersonline href='viewprofile.php?viewuser=$i->username' style=\"\">$echo</a> "?></b></a> <i><? echo $rows['a_datetime']; ?></i>
<?
if ($userlevel >= 15)
{
?>
-<a href="deletepost.php?a_id=<? echo $id2 ?>">Delete!</a><?
}
?>
</td>
</tr>
<tr>
<td width="99%" bgcolor="#222222" valign="top"><basefont color="ffffff"><? echo dobbcodes($rows['a_answer']); ?></basefont></td>
</tr>
</table>
<?
}
mysql_close();
?>
<BR><br><br><br>
<form name="form1" method="post" action="">
<table border=1 cellspacing=0 align="center" cellpadding=2 bordercolor=black width=75% class=sub2>
<tr>
<td class=header>Add Reply:
</td>
</tr>
<tr>
<td>
<center><textarea name="a_answer" cols="45" style='width: 90%; border:1px solid black; height: 150px' bgcolor="#222222" rows="3" id="a_answer"></textarea></center></td></tr>
<tr><td>
<input name="id" type="hidden" value="<? echo $id; ?>">
<input type="submit" name="Submit" value="Reply">
<b><?
if ($crewlevel >= 7)
{
?>
<a href="Crewforum.php?sticky=<? echo $id ?>">Sticky</a > -
<a href="Crewforum.php?unsticky=<? echo $id ?>">Unsticky</a> -
<a href="Crewforum.php?important=<? echo $id ?>">Important</a> -
<a href="Crewforum.php?unimportant=<? echo $id ?>">Unimportant</a> -
<a href="Crewforum.php?lock=<? echo $id ?>">Lock</a> -
<a href="Crewforum.php?unlock=<? echo $id ?>">Unlock</a> -
<a href="Crewforum.php?delete=<? echo $id ?>">Delete</a>
</b>
<?
}
?>
<?
if ($title == $username)
{?>
-<a href="edittopic.php?id=<? echo $id ?>">Edit</a>
<?
}
?>
</td></tr>
</table></form>
</td>
<TD width="150" valign="top">
<?php include("rightmenu.php");?>
</TD>
</TR>
</table>
</center>
</body>
</html>
The problem is that the field 'a_answer' should contain a users comment, such as the box I'm writing in now, but its not going into the database, the username and date are but not actual comment, if anyone could take a quick look it would be much appreciated,