Comunidad de diseño web y desarrollo en internet online

Recuperar un "id" de un desplegable

Citar            
MensajeEscrito el 12 Nov 2009 10:21 am
Hola a todos. Por mas vueltas que le doy... estoy dando palos de ciego y no doy con la solución. Os pongo un poco al dia:

Tengo un desplegable con 100 empresas. Yo selecciono una empresa del desplegable y pulso un botón de aceptar. Seguidamente se me abre un menu con opciones en la que una de esas opciones es un GESTOR DE TAREAS.

Pues bien, lo que quiero es que cuando yo inserte una nueva tarea en el gestor de tareas me capture el identificador de la sociedad que yo elegí en el desplegable del principio, así cuando yo inserte los campos en la tabla tareas(id_tarea,id_soci,usuario,tarea,tiempo,fecha ) aparezca en base de datos el "id_soci" que yo elegí en el desplegable.

Os pongo a continuación lo que hago:


Menú donde pongo las opciones y recojo por URL el valor de la sociedad que yo he elegido en el desplegable.

Código PHP :

<?php
$ruta=$_POST['pob1'];

<?

<div class="titulo"><h3>- MENU - <BR>Seleccione la opción deseada</h3></div>
</td>
</tr>
<tr>
<td colspan="2">
<div id="Seleecione la opción deseada">
<table border="1" bordercolor="navy" cellspacing="0" cellpadding="0" valign="top" width="100%">
<tr>
<td colspan="2" class="celda" name="casilla1.1" id="casilla1.1">
<center><a href="consulta/consultardatos.php?pob1=<?php echo $ruta; ?> " target="cuerpo"><font color="red"> Datos de la sociedad</a></font>
</td>
</tr> 

<tr>
<td colspan="2" class="celda" name="casilla1.2" id="casilla1.2">
<center><a href="consulta/tareas.php?pob1=<?php echo $ruta; ?>" target="cuerpo"><font color="red">GESTOR DE TAREAS</a></font>
</td>
</tr> 


tareas.php

Código PHP :

 

<?php 

$ruta=$_GET['pob1'];

require_once('funciones.php'); 


encabezado_html('INSERTAR NUEVA TAREA');
$id=$_GET['id'];
form_mostrar_tarea();
?>



form_mostrar_tarea

Código PHP :

function form_mostrar_tarea($vino = '')

{ 

$edit = is_array($vino);


?>
<form method=post
action="<?php echo $edit?'editar_tarea.php':'insertar_tarea.php';?>">
<table border=0>


<tr>
<td></td>
<td><input type=hidden name=id_tarea 
value="<?php echo $edit?$vino['id_tarea']:''; ?>"></td>
</tr>


<tr>
<td></td>
<td><input type=hidden name=id_soci 
value="<?php echo $edit?$vino['id_soci']:''; ?>"></td>
</tr>




<tr>
<td>Usuario:</td>
<td><input type=text name=usuario
value="<?php echo $edit?$vino['usuario']:''; ?>"></td>
</tr>
<tr>
<td>Tarea:</td>
<td><input type=text name=tarea maxlength=500 size=100
value="<?php echo $edit?$vino['tarea']:''; ?>"></td>
</tr>

<tr>
<td>Tiempo:</td>
<td><input type=text name=tiempo 
value="<?php echo $edit?$vino['tiempo']:''; ?>"> </td>
</tr>

<tr>
<td>Fecha:</td>
<td><input type=text name=fecha 
value="<?php echo $edit?$vino['fecha']:''; ?>"> </td>
</tr>

<tr>
<td <?php if (!$edit) echo 'colspan=2'; ?> align=center>
<?php 
if ($edit)

echo '<input type=hidden name=antiguovinosid 
value="'.$vino['id_tarea'].'">';
?>
<input type=submit
value="<?php echo $edit?'Actualizar':'Agregar'; ?> tarea">
</form></td>
<?php 
if ($edit)
{ 
echo '<td>';
echo '<form method=post action="eliminar_tarea.php">';
echo '<input type=hidden name=ide_tarea 
value="'.$vino['id_tarea'].'">';
echo '<input type=submit 
value="Eliminar tarea">';
echo '</form></td>';
}
?>
</td>
</tr>
</table>
</form>

}


insertar_tarea.php

Código PHP :

 
<?php session_start();

$ruta=$_GET['pob1'];

require_once('funciones.php'); 


encabezado_html('Agregando una tarea');

$id_tarea = $HTTP_POST_VARS['id_tarea'];
$id_soci = $HTTP_POST_VARS['id_soci'];
$usuario = $HTTP_POST_VARS['usuario'];
$tarea = $HTTP_POST_VARS['tarea'];
$tiempo = $HTTP_POST_VARS['tiempo'];
$fecha = $HTTP_POST_VARS['fecha'];



?> <h3> <?php
if(insertar_tarea($id_tarea, $id_soci, $usuario, $tarea, $tiempo, $fecha))

echo "Tarea '".stripslashes($tarea)."' fue agregada a la base de datos.<br />";

else

echo "Tarea'".stripslashes($tarea).

"' No puede ser agregada a la base de datos.<br />";

?> 
<form><input type=button value="<< Volver" onClick="history.go(-1);"></form>

<?php

function insertar_tarea($id_tarea, $id_soci, $usuario, $tarea, $tiempo, $fecha)

{

$con = conexion_bd();


$query = "select *
from tareas 
where id_tarea='$id_tarea'";

$result = mysql_query($query);
if (!$result || mysql_num_rows($result)!=0)
return false;


$query = "insert into tareas values
('$id_tarea', '$id_soci', '$usuario', '$tarea', '$tiempo', '$fecha')";



$result = mysql_query($query);
if (!$result)
return false;
else
return true;
}

No se como recuperar el valor de $ruta que yo recojo en el desplegable ni donde tengo que ponerlo. Agradecería vuestra ayuda.

Por sneider

1 de clabLevel



 

msie
Citar            
MensajeEscrito el 12 Nov 2009 04:38 pm
Lo más recomendable es que agregues un campo "hidden" al segundo formulario que contenga el valor que deseas recuperar después. Luego lo recuperas por $_POST.

Por Odin

Claber

639 de clabLevel

2 tutoriales

Genero:Masculino   Premio_Secretos

El valle de las hamacas

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.