Foros del Web » Programando para Internet » PHP »

Se puede hacer esto???

Estas en el tema de Se puede hacer esto??? en el foro de PHP en Foros del Web. Hola a todos, tengo una duda... (entre otras), esto se puede hacer???: Código PHP: <form action= " <?  if(isset( $_POST [ "AnyadirDocumento" ])) { echo  "InsercionDocumento.php" ;} else { echo  "AnyadirDoc.php" ;}  ...
  #1 (permalink)  
Antiguo 09/05/2005, 03:20
 
Fecha de Ingreso: mayo-2005
Mensajes: 78
Antigüedad: 18 años, 10 meses
Puntos: 0
Se puede hacer esto???

Hola a todos, tengo una duda... (entre otras), esto se puede hacer???:
Código PHP:
<form action= "<? if(isset($_POST["AnyadirDocumento"])) { echo "InsercionDocumento.php";} else { echo "AnyadirDoc.php";} ?>" method="post" enctype="multipart/form-data" name="form1">
Lo de $_POST["AnyadirDocumento"] es un boton...

Cuando lo hago no me funciona a la primera, es decir, si le doy dos veces si que me redirecciona a InsercionDocumento, si le doy solo una vez me redireccion a AnyadirDoc... xq???


Gracias!!!
  #2 (permalink)  
Antiguo 09/05/2005, 03:29
 
Fecha de Ingreso: mayo-2005
Mensajes: 78
Antigüedad: 18 años, 10 meses
Puntos: 0
Cuando lo hago no me funciona a la primera, es decir, si le doy dos veces si que me redirecciona a InsercionDocumento, si le doy solo una vez me redireccion a AnyadirDoc... xq???
  #3 (permalink)  
Antiguo 09/05/2005, 03:30
Avatar de jam1138
/** @package Moderador */
 
Fecha de Ingreso: julio-2004
Ubicación: sèveR led onieR lE
Mensajes: 9.368
Antigüedad: 19 años, 7 meses
Puntos: 102
Se puede... pero ... ¿por qué dices que "sí te redirecciona"? ... ... ve el código fuente que te imprime... quizá debas mostrar todo tu forma... incluyendo el botón... y el nombre de la página... ¿alguno de los actions corresponde a la mima página??... y claro... explicar ampliamente qué quieres hacer...

__________________
٩(͡๏̯͡๏)۶
» Cómo hacer preguntas de manera inteligente «

"100 años después, la revolución no es con armas, es intelectual y digital"
  #4 (permalink)  
Antiguo 09/05/2005, 03:35
 
Fecha de Ingreso: mayo-2005
Mensajes: 78
Antigüedad: 18 años, 10 meses
Puntos: 0
Veamos, mas ampliamente, hay un formulario para rellenar con campos de texto y movidas, lo que quiero es que cuando le de al ultimo boton (añadir documento) me vaya al php adecuado (inserciondocumento.php), el problema esta en, si le doy una vez pasa de mi y va a anyadirdoc.php. Todo el codigo es:

Código PHP:
<form action= "<? if(isset($_POST["AnyadirDocumento"])) { echo "InsercionDocumento.php";} else { echo "AnyadirDoc.php";} ?>" method="post" enctype="multipart/form-data" name="form1">
  <table width="200" border="0">
    <tr>
      <td><div align="center"><u><strong><span class="style1">A&Ntilde;ADIR DOCUMENTO</span></strong></u></div></td>
    </tr>
  </table>
  <table width="308" border="0">
    <tr>
      <td width="64">Nombre:</td>
      <td width="240"><input name="nombre" type="text" size="50" value="<? echo $_POST['nombre']; ?>" ></td>
    </tr>
  </table>
  <table width="240" border="0">
    <tr>
      <td width="81">Referencia:</td>
      <td width="149"><input type="text" name="referencia" value="<? echo $_POST['referencia']; ?>"></td>
    </tr>
  </table>
  <table width="402" border="0">
    <tr>
      <td width="239">Fecha de publicaci&oacute;n (dd-mm-aaaa): </td>
      <td width="153"><input type="text" name="fecha" value="<? echo $_POST['fecha']; ?>"></td>
    </tr>
  </table>
  <table width="298" border="0">
    <tr>
      <td>N&uacute;mero de p&aacute;ginas: </td>
      <td><input type="text" name="paginas" value="<? echo $_POST['paginas']; ?>"></td>
    </tr>
  </table>
  <table width="596" border="0">
    <tr>
      <td width="102" height="100">Resumen:</td>
      <td width="484"><textarea name="resumen" cols="75" rows="5"><? echo $_POST['resumen']; ?></textarea></td>
    </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="267" border="0">
    <tr>
      <td width="154">Tipo de documento: </td>
      <td width="103"><p>
          <label> </label>
          <label> </label>
          <select name="tipoDoc" onChange="cambiarTipo()">
            <option value="Libro">Libro
            <option value="Articulo">Articulo
          </select>
          <br>
      </p></td>
    </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td><div align="center"><strong><span class="style1">AUTORES</span></strong></div></td>
    </tr>
  </table>
  <table width="608" border="0">
    <tr>
      <td><? if(count($_POST['nombreAut']) > 0)
            {
                foreach(
$_POST["nombreAut"] as $nomAut)
                {
                    
//echo "<br>DNI: "."$dni";
                
?>
                    <input type="hidden" name="nombreAut[]" value="<? echo $nomAut?>">
    <tr><td>AUTOR: </td><td><? echo $nomAut; echo "<br>"?></td></tr>
                <?
                

            }
        
?> 
       </td>
      <td width="135">Nombre y Apellidos:</td>
      <td width="463"><input type="text" name="nombreAut[]" width="450"></td>
    </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="487" border="0">
    <tr>
      <td width="481"><div align="right">
        <input type="submit" name="AnyadirAutor" value="Añadir Autor">
      </div></td>
    </tr>
  </table>
  
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="521" border="0">
    <tr>
      <td width="224" height="38"><div align="center"><strong><span class="style1">CAT&Aacute;LOGO/S ASOCIADOS </span></strong></div></td>
    </tr>
  </table>
  <table width="234" border="0">
    <tr>
      <td><? if(count($_POST['nomCat']) > 0)
            {
                foreach(
$_POST["nomCat"] as $nomCat)
                {
                    
//echo "<br>DNI: "."$dni";
                
?>
                    <input type="hidden" name="nomCat[]" value="<? echo $nomCat?>" >
    <tr><td>CATÁLOGO: </td><td><? echo $nomCat; echo "<br>"?></td></tr>
                <?
                

            }
        
?> 
       </td>
      <td width="67">Nombre:</td>
        <td width="157"><input type="text" name="nomCat[]"></td>
      </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="499" border="0">
    <tr>
      <td width="481"><div align="right">
          <input type="submit" name="AsignarCatalogo" value="Asignar Catálogo">
      </div></td>
    </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td><div align="center"><strong><span class="style1">TEM&Aacute;TICA</span></strong></div></td>
    </tr>
  </table>
  <table width="234" border="0">
    <tr>
      <td><? if(count($_POST['nomTema']) > 0)
            {
                foreach(
$_POST["nomTema"] as $nomTema)
                {
                    
//echo "<br>DNI: "."$dni";
                
?>
                    <input type="hidden" name="nomTema[]" value="<? echo $nomTema?>" >
    <tr>
                      <td>TEMA: </td>
                      <td><? echo $nomTema; echo "<br>"?></td></tr>
                <?
                

            }
        
?> 
       </td>
      <td width="67">Nombre:</td>
      <td width="157"><input type="text" name="nomTema[]"></td>
    </tr>
  </table>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="499" border="0">
    <tr>
      <td width="481"><div align="right">
        <input type="submit" name="AnyadirTema" value="A&ntilde;adir Tema">
      </div></td>
    </tr>
  </table>
  <div id="Articulo" style="position:absolute; width:200px; height:115px; z-index:2; visibility: hidden; left: 11px; top: 341px;">
  <table width="200" border="0">
    <tr>
      <td><div align="center"><strong><span class="style1">ART&Iacute;CULO</span></strong></div></td>
    </tr>
  </table>
  <table width="430" border="0">
    <tr>
      <td width="79">Gratuito    
        <input name="radiobutton" type="radio" value="gratuito" <? if ($_POST['radiobutton'] == "gratuito") { echo "checked"; } ?>></td>
      <td width="65">Pago
        <input name="radiobutton" type="radio" value="pago" <? if ($_POST['radiobutton'] == "pago") { echo "checked"; } ?>></td>
      <td width="68"><div align="right">Importe:</div></td>
      <td width="153"><input type="text" name="importe" value="<? echo $_POST['importe']; ?>"></td>
      <td width="43"><div align="left">&euro;</div></td>
    </tr>
  </table>
  <table width="432" border="0">
    <tr>
      <td width="48"><div align="left">Ruta:</div></td>
      <td width="374"><input type="text" name="rutaArt" value="<? echo $_POST['rutaArt']; ?>"></td>
    </tr>
  </table>
  </div>
  <table width="200" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <div id="Libro" style="position:absolute; width:409px; height:163px; z-index:1; top: 341px; left: 12px; visibility: visible;">
  <table width="200" border="0">
    <tr>    
      <td><div align="center"><strong><span class="style1">LIBRO</span></strong></div></td>
    </tr>
  </table>  
  <table width="200" border="0">
    <tr>
      <td width="46">ISBN:</td>
      <td width="144"><input type="text" name="isbn" value="<? echo $_POST['isbn']; ?>"></td>
    </tr>
  </table>
  <table width="216" border="0">
    <tr>
      <td width="62">Editorial:</td>
      <td width="144"><input type="text" name="editorial" value="<? echo $_POST['editorial']; ?>"></td>
    </tr>
  </table>
  <table width="212" border="0">
    <tr>
      <td width="58">Edici&oacute;n:</td>
      <td width="144"><input type="text" name="edicion" value="<? echo $_POST['edicion']; ?>"></td>
    </tr>
  </table>
  <table width="405" border="0">
    <tr>
      <td width="80">Digital
      <input type="checkbox" name="digital" value="digital" <? if ($_POST['digital'] == "digital") { echo "checked"; } ?>></td>
      <td width="90"><div align="right">Ruta:</div></td>
      <td width="221"><input type="text" name="rutaLD" value="<? echo $_POST['rutaLD']; ?>"></td>
    </tr>
  </table>  
  <table width="200" border="0">
    <tr>
      <td>F&iacute;sico
      <input type="checkbox" name="fisico" value="fisico" <? if ($_POST['fisico'] == "fisico") { echo "checked"; } ?>></td>
    </tr>
  </table>
  </div>
  <table width="488" border="0">
    <tr>
      <td width="482"><div align="right">
        <input type="submit" name="AnyadirDocumento" value="A&ntilde;adir Documento">
      </div></td>
    </tr>
  </table>

</form>
Gracias
  #5 (permalink)  
Antiguo 09/05/2005, 03:50
Avatar de jam1138
/** @package Moderador */
 
Fecha de Ingreso: julio-2004
Ubicación: sèveR led onieR lE
Mensajes: 9.368
Antigüedad: 19 años, 7 meses
Puntos: 102
Aahhh!!!.. ya cacho... es simple.

- Abres tu página ¿existe $_POST['boton']?; NO!... action="AnyadirDoc.php"...
- Daz a tu botón... a dónde te lleva?? a lo que tiene tu action (la misma página?; no aclaras)... se lo asignaste en el paso anterior
- Recargando la página... vuelve a preguntar ¿existe $_POST['boton']?; SÍ!... action="InsercionDocumento.php"... pero solo te imprime eso en el action... para nada estás enviando el formulario... solo lo recibes... Ojo...

Tu buscas algo en JavaScript... ya se ha tratado. Suerte!
__________________
٩(͡๏̯͡๏)۶
» Cómo hacer preguntas de manera inteligente «

"100 años después, la revolución no es con armas, es intelectual y digital"
  #6 (permalink)  
Antiguo 09/05/2005, 03:52
Avatar de jam1138
/** @package Moderador */
 
Fecha de Ingreso: julio-2004
Ubicación: sèveR led onieR lE
Mensajes: 9.368
Antigüedad: 19 años, 7 meses
Puntos: 102
De hecho.. se esta tratando: http://www.forosdelweb.com/f13/poner-2-botones-submit-formulario-296087/
__________________
٩(͡๏̯͡๏)۶
» Cómo hacer preguntas de manera inteligente «

"100 años después, la revolución no es con armas, es intelectual y digital"
  #7 (permalink)  
Antiguo 09/05/2005, 03:54
 
Fecha de Ingreso: mayo-2005
Mensajes: 78
Antigüedad: 18 años, 10 meses
Puntos: 0
Algo ene javascript? Como lo puedo buscar? Hechame una mano.,..
  #8 (permalink)  
Antiguo 09/05/2005, 03:56
 
Fecha de Ingreso: mayo-2005
Mensajes: 78
Antigüedad: 18 años, 10 meses
Puntos: 0
ok, vale, gracias, t as adelantado... ;) ;)
  #9 (permalink)  
Antiguo 09/05/2005, 04:01
 
Fecha de Ingreso: mayo-2005
Mensajes: 78
Antigüedad: 18 años, 10 meses
Puntos: 0
Vale, ya esta solucionado, muchas gracias, lo que me falta aun es lo que se repite al añadirlo a una lista cndo el textbox esta en blanco...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:01.