<? include('checkcookie.php'); ?>
<h3>Форум/сообщения</h3>
<br>
<?
if (isset($_POST["id"]))
{
	$id=$_POST["id"];
	$urlsite=$_POST["urlsite"];
	$urlpic=$_POST["urlpic"];
	
	
	mysql_query("update forum set ogl='$urlsite', text='$urlpic' where id='$id'");
	echo "<font color=\"#00dd00\"><b>Сохранено.</b></font><br><br>";
}

if (isset($_GET["id"]))
{
	$id=$_GET["id"];
	$option=$_GET["option"];

if ($option=="delete")
	{
		mysql_query("DELETE FROM forum WHERE id='$id'");
		echo "<font color=\"#dd0000\"><b>Тема удалена.</b></font><br><br>";
	}

	if ($option=="edit")
	{
		$urlsite=$_POST["urlsite"];
		$urlpic=$_POST["urlpic"];
		

		?>
		<form method="post" action="adminmain.php?p=admforumSOB&option=save">
			<b>Тема:</b>&nbsp;<input type="text" name="urlsite" size="30" maxlength="150" value="<?=$urlsite ?>"><br>
			<b>Описание:</b>&nbsp;<input type="text" name="urlpic" size="30" maxlength="150" value="<?=$urlpic ?>"><br>
			<br>
			<input type="hidden" value="<?=$id ?>" name="id">
			<input type="submit" value="Сохранить">
		</form>
		<?
	}
}
?>

<table width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<th>ID</th>
		<th>Тема</th>
		<th>Описание</th>
		<th>Автор</th>
                <th>Дата</th>
		<th></th>
		<th></th>
	</tr>
<?
$tabla = mysql_query("SELECT * FROM forum where tema='0' ORDER BY id ASC");
while ($registro = mysql_fetch_array($tabla)) {

echo "
<tr>
<td>". $registro["id"] ."</td>
<td>". $registro["ogl"] ."</td>
<td>". $registro["text"] ."</td>
<td>". $registro["user"] ."</td>
<td>". $registro["data"] ."</td>
";
echo "<td>";
?>
<form method="post" action="adminmain.php?p=admforumSOB&id=<?= $registro["id"] ?>&option=edit">
<input type="hidden" name="urlsite" value="<?=$registro["ogl"] ?>">
<input type="hidden" name="urlpic" value="<?=$registro["text"] ?>">

<input type="submit" value="Редактировать" class="button">
</form>
</td>
<td>
<form method="post" action="adminmain.php?p=admforumSOB&id=<?= $registro["id"] ?>&option=delete">
<input type="submit" value="Удалить" class="button">
</form>
</td>
</tr>
<?
} 
?>
</table>




