Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/04/2004, 01:03
chari
 
Fecha de Ingreso: diciembre-2002
Mensajes: 130
Antigüedad: 21 años, 4 meses
Puntos: 0
boton formulario

Como puedo crear un boton en un formulario que recarge la misma pagina del formulario, pero cada vez que pinche en un boton diferente pase una variable diferente, no se explicarme, os muestro el codigo que utilizo.

<?
include ("../calendario/calendario/calendario.php");
include_once ("../auth.php");
include_once ("../authconfig.php");
include_once ("../check.php");
?>
<script language="JavaScript">

function cerrar() {
var ventana = window.self;
ventana.opener = window.self;
ventana.close();
}
</script>
<?
$connection = mysql_connect($dbhost, $dbusername, $dbpass);
$SelectedDB = mysql_select_db($dbname);

$tabla = mysql_query("SELECT fecha_ultimo_apunte FROM PERSONAL WHERE CODIGO= '$codigo'");
$rows = mysql_fetch_array($tabla);

$codigo = $check["CODIGO"];
$fecha = $check["fecha_ultimo_apunte"];

$dia=substr($fecha,8,2);
$mes=substr($fecha,5,2);
$anio=substr($fecha,0,4);
$fechagraba=$anio.'/'.$mes.'/'.$dia;


if ($check["NIVEL"] >= 9)
{
// Feel free to change the error message below. Just make sure you put a "\" before
// any double quote.
print "<font face=\"Arial, Helvetica, sans-serif\" size=\"5\" color=\"#FF0000\">";
print "<b>Illegal Access</b>";
print "</font><br>";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#000000\">";
print "<b>You do not have permission to view this page.</b></font>";

exit; // End program execution. This will disable continuation of processing the rest of the page.
}
?>
<html>
<head>
<title>Introducci&oacute;n de horas Proyectos Vigentes</title>
<script language="JavaScript" src="../calendario/calendario/javascripts.js"></script>
</head>

<body>
<form name="fcalen" method="post" action="insertar.php">
<table width="578" border="0">
<tr>
<td width="250" height="28">FECHA</td>
<td width="318">
<?
echo $fechagraba;
escribe_formulario_fecha_vacio("fecha1","fcalen");
?>

</td>
</tr>
<tr>
<td height="28">PROYECTO</td>
<td><select name="proyecto" size="1">
<?

if (opcion == "si")
{
$listanombre = mysql_query("select * from PROYECTOS WHERE VIGENTE = '1' order by NOMBRE ASC ");
}
else
{
$listanombre = mysql_query("select * from PROYECTOS order by NOMBRE ASC ");
}

$row = mysql_fetch_array($listanombre);
while($row){
$nomlista = $row["CODIGO"];
print "<option value=\"$nomlista\">" . $row["NOMBRE"] . "</option>";
$row = mysql_fetch_array($listanombre);
}
?>
</select></td>
</tr>
<tr>
<td height="28">HORAS</td>
<td><input name="horas" type="text" id="horas"></td>
</tr>
<tr>
<td height="28">COMENTARIO</td>
<td><input name="comentario" type="text" id="comentario" size="50">
</td>
</tr>
<tr>
<td height="57"><b onClick="window.open('horas.php','','width=600,hei ght=225,scrollbars=yes')"><a href="#"><img src="../boton_horas.gif" alt="Horas" width="25" height="25" hspace="10" border="0"></a></b><b onClick="window.open('prueba.php','','width=600,he ight=225,scrollbars=yes')"></b><b onClick="window.open('prueba2.php','','width=600,h eight=225,scrollbars=yes')"></b><b onClick="window.open('horas3.php','','width=600,he ight=225,scrollbars=yes')"><a href="#"><img src="../boton_horas.gif" alt="Horas Introducidas" width="25" height="25" hspace="10" border="0"></a></b><b onClick="window.open('prueba2.php','','width=600,h eight=225,scrollbars=yes')"></b></td>
<td valign="middle"><input type="Submit" name="enviar" value="Guardar">
<input type="reset" name="borrar" value="Borrar">
<a href="#" onClick="cerrar()"><img src="../boton_cerra.gif" alt="Cerrar ventana" width="21" height="21" border="0"></a>
<a href="prueba2.php"><img src="../boton_proyectos.gif" alt="Todos los Proyectos" width="77" height="18" hspace="10" border="0"></a></td>
</tr>
</table>
</form>
<? if (opcion == "si")
{
echo "<form name=\"form1\" method=\"post\" action=\"horas2.php?opcion=si\">";
echo "<input type=\"submit\" name=\"Submit\" value=\"Proyectos\">";
}
else
{
echo "<form name=\"form1\" method=\"post\" action=\"horas2.php?opcion=no\">";
echo "<input type=\"submit\" name=\"Submit\" value=\"Proyectos Vigentes\">";
}
?>
</form>
</body>
</html>

No se porque siempre me coge el else. Nunca entra en el if.

Ayudarme. Gracias