Ver Mensaje Individual
  #14 (permalink)  
Antiguo 12/01/2009, 20:26
letni
 
Fecha de Ingreso: octubre-2008
Mensajes: 276
Antigüedad: 15 años, 6 meses
Puntos: 1
Respuesta: Redireccionar con botones

Hola acumulador, puedes tener un botón que realice el submit:

Código HTML:
<input value = "Botón Enviar" class = "boton" type = "submit" /> 
y el resto que redireccionen:

Código HTML:
<input value = "Botón Redireccón 1" class = "boton" type = "button" onclick = "javascript:window.location='archivo1.php'">

<input value = "Botón Redireccón 2" class = "boton" type = "button" onclick = "javascript:window.location='archivo2.php'">

<input value = "Botón Redireccón 3" class = "boton" type = "button" onclick = "javascript:window.location='archivo3.php'"> 
o todos que redireccionen y ninguno que haga submit, por ejemplo.

Yo lo hago así pero también está la opción de hacer switch.

Haces todos los botones tipo submit:

Código HTML:
<form action = "test.php" method = "post">
   <input type = "submit" name = "accion" value = "Acceder" />
   <input type = "submit" name = "accion" value = "Registrarse" />
</form> 
test.php

Código PHP:
<?php
   
switch($_POST['accion']) {
   case 
'Acceder':
      
header("Location: formulario_acceder.htm"); // Te llevará a la página formulario_acceder.htm
      
break;
   case 
'Registrarse':
      
header("Location: formulario_registrarse.htm"); // Te llevará a la página formulario_registrarse.htm
      
break;
}
?>
Yo lo hago sin el switch para tener el código en archivos php separados.

Espero que te sirva.

Saludos.

Última edición por letni; 12/01/2009 a las 20:32