<?php
session_start();
include('../db.php');

if (!session_is_registered("clave_audio")) {
	include("../login.php");
	if (!$continuar) exit;
}
?>
<html>
<head>
<title>glosario</title>
<link href="../sformi.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function doSubmit() { 
	document.formulario.submit();
}
</script>
</head>
<body>
<?php 
if(isset($_REQUEST['op'])) {
	$operacion = $_REQUEST['op'];
	$id = $_REQUEST['id'];
} else {
	$operacion = "add";
}
?>
<?php
$glosario_palabra = "";
$glosario_descripcion = "";

if($operacion == 'edit') {
	$conn = db_connect();
	if($conn) {
		$query = "SELECT glosario_palabra, glosario_descripcion FROM edito_glosario WHERE glosario_id = " . $id;
		$result = mysql_query($query, $conn);
		if (mysql_num_rows($result)) {
			$row = mysql_fetch_array($result);
			$glosario_palabra = $row['glosario_palabra'];
			$glosario_descripcion = $row['glosario_descripcion'];
		}
	}
}
?>
<form method="post" action="glosario_db.php" name="formulario">
<input name="op" type="hidden" value="<?php echo $operacion; ?>">
<input name="id" type="hidden" value="<?php echo $id; ?>">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td width="150" class= "lbl">Palabra</td></tr>
<tr><td width="450" class="data"><input name="glosario_palabra" type="text" size="80" maxlength="150" value="<?php echo $glosario_palabra; ?>"></td></tr>
<tr><td><img src="_imgs/d.gif" width="100" height="10"></td></tr>
<tr><td width="150" class= "lbl">Descripci&oacute;n</td></tr>
<tr><td width="450" class="data"><textarea name="glosario_descripcion" cols="80" rows="5"><?php echo $glosario_descripcion; ?></textarea></td></tr>
<tr><td><img src="_imgs/d.gif" width="100" height="10"></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td>
		<a href="javascript:history.go(-1)" class="button">[ Cancelar ]</a>&nbsp;&nbsp;
		<a href="javascript:doSubmit();" class="button">[ Grabar ]</a>
<?php
	if($operacion == 'edit') {
?>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="glosario_db.php?op=del&id=<?php echo $id; ?>" class="button">[ borrar ]</a>
<?php
	}
?>
	</td>
	</tr>
</table>
</form>
</body>
</html>