<?php
session_start();

include "../functions.php";
checkAdmin(session_id());

if ($_POST["submit"] == 1)
{
	$typeid = $_POST["typeid"];
	$typename = $_POST["typename"];
	$typedescrip = $_POST["typedescrip"];
	
	$query = "update movetype set typename='$typename', typedescrip='$typedescrip' where typeid='$typeid'";
	mysql_query($query) or die (mysql_error());
	header ("location: type.php");
}
?>

<?php
include "header.php";

$typeid = $_POST["typeid"];

$query = "select typename, typedescrip from movetype where typeid='$typeid'";
$result = mysql_query($query) or die (mysql_error());
if ($row = mysql_fetch_array($result))
{
	$typename = $row[0];
	$typedescrip = $row[1];
}
?>

<script language="javascript">
function checkform(form)
{
	if (form.typename.value == "")
	{
		alert("Please enter a type name.");
		form.typename.focus();
		return false;
	}
}
</script>
<center>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" onsubmit="return checkform(this)">
<table  cellspacing=0 cellpadding=3 border=0>
  <tr>
    <td>Name</td>
    <td><input type="text" name="typename" value="<?php echo $typename; ?>"></td>
  </tr>
  
  <tr>
    <td valign="top">Description</td>
    <td><textarea name="typedescrip" rows=5 cols=30 wrap="virtual"><?php echo $typedescrip; ?></textarea></td>
  </tr>
  
  <tr>
    <td colspan=2 align="center"><input type="hidden" name="submit" value="1"><input type="hidden" name="typeid" value="<?php echo $typeid; ?>"><input type="submit" value="Modify">&nbsp;<input type="reset" value="Cancel"></td>
  </tr>
</table>
</form>
</center>

<?php
include "footer.php";
?>