Ver Mensaje Individual
  #8 (permalink)  
Antiguo 07/03/2012, 05:34
Fierox
 
Fecha de Ingreso: febrero-2012
Ubicación: En mi propio mundo
Mensajes: 73
Antigüedad: 12 años, 2 meses
Puntos: 23
Respuesta: mas de un submit en mismo formulario

Como ya le explique a nobo por privado, para la gente que esta empezando con php no es recomendable ponerse con ajax, porque aun no entiende bien como se realizan las peticiones al servidor.

En cuanto lo que quiere hacer nobo se puede resolver con sessiones.

Añade una variable de sesion llamada radio por ejemplo, asi cuando envíes el form a carrito_finalizacion.php la puedes recoger facilmente con $_SESSION["radio"]

Código PHP:
if ( (isset($_SERVER['HTTP_REFERER'])) and ($_SERVER['HTTP_REFERER'] == 'http://localhost/zulo/carrito_forma_pago.php' ))
{
    switch (
$_POST["radio"]) {
        case 
1:$_SESSION["radio"] = 1;break;
        case 
2:$_SESSION["radio"] = 2;break;
        case 
3:$_SESSION["radio"] = 3;break;
    }
    echo 
"has elegido el metodo de pago ".TextoTipoPago($_POST["radio"]); 
    if ( isset(
$_POST["button"]) )
    {
        
header('Location: carrito_finalizacion.php');
    }



Y para que un radio esté checked según el radio que hayas seleccionado

Código HTML:
Ver original
  1. <form id="form1" name="form1" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
  2.         <p>
  3.        <?php
  4.        if ( isset($_SESSION["radio"]) && $_SESSION["radio"]==1 )
  5.        {
  6.            echo '<input name="radio" type="radio" id="radio" value="1" checked="checked" onclick="this.form.submit();" />';
  7.         } else
  8.         {
  9.             echo  '<input name="radio" type="radio" id="radio" value="1" onclick="this.form.submit();" />';
  10.         }
  11.        ?>
  12.         <label for="radio">Contra reembolso <?php echo $_SESSION["totalcompra"] + 8; ?></label><br />
  13.    
  14.     <?php
  15.        if ( isset($_SESSION["radio"]) && $_SESSION["radio"]== 2 )
  16.        {
  17.            echo '<input name="radio" type="radio" id="radio" value="2" checked="checked" onclick="this.form.submit();" />';
  18.         } else
  19.         {
  20.             echo  '<input name="radio" type="radio" id="radio" value="2" onclick="this.form.submit();" />';
  21.         }
  22.        ?>
  23.         <label for="radio">Transferencia</label><br />
  24.        
  25.        <?php
  26.        if ( isset($_SESSION["radio"]) && $_SESSION["radio"]==3 )
  27.        {
  28.            echo '<input name="radio" type="radio" id="radio" value="3" checked="checked" onclick="this.form.submit();" />';
  29.         } else
  30.         {
  31.             echo  '<input name="radio" type="radio" id="radio" value="3" onclick="this.form.submit();" />';
  32.         }
  33.        ?>
  34.         <label for="radio">PayPal</label><br />
  35.         </p>
  36.  
  37.         <p>
  38.             <input type="submit" name="button" id="button" value="Pagar" />
  39.         </p>
  40. </form>