<?php
session_start();
include "../conn.php";
include "../functions.php";

$userID = checkAdmin(session_id());

$roomid = $_POST["fid"];

if ($_POST["act"] == "mod")
{
	$roomname = trim($_POST["roomname"]);
	$descr = trim($_POST["descr"]);
	if ($roomname == "")
	{
		$err = "Name cannot be empty";
	}
	else
	{
		mysql_query("update room set roomname='$roomname', descr='$descr' where roomid=$roomid");
		header ("location: f.php");
	}
}

$res = mysql_query("select roomname, descr from room where roomid=$roomid");
$roomname = mysql_result($res, 0, 0);
$descr = mysql_result($res, 0, 1);

include "fheader.php";
echo "<form action=modf.php method=post><table width=80% align=center cellspacing=1 cellpadding=3>";
if ($err)
echo "<tr><td align=center><font color=red>$err</font></td></tr>";
echo "<tr><td><b>Room Name:</b><br><input type=text name=roomname value=\"$roomname\"></td></tr>";
//echo "<tr><td><b>Description:</b><br><textarea name=descr rows=5 cols=30 wrap=virtual>$descr</textarea></td></tr>";
echo "<input type=hidden name=fid value=$roomid><input type=hidden name=act value=mod><tr><td><input type=submit value=Modify></td></tr>";
echo "</table>";

include "adminFooter.php";
?>