Ver Mensaje Individual
  #19 (permalink)  
Antiguo 03/07/2012, 15:44
pzenteno22
 
Fecha de Ingreso: junio-2012
Mensajes: 17
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: Validar checkbox en php

Este es el codigo html:

<h2>PANEL DE CONTROL DE BITACORA DE TI</h2>

<form method="post" name="fpanel" id="fpanel" action="udt.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="boxt">
<tr>
<th colspan="8" scope="col">Estado al: </th>
</tr>
<tr>

<th>Area</th>
<th>Servicio</th>
<th>Aplicación</th>
<th>Soporte Hardware y Software Base</th>
<th>Estado </th>
<th>Revisión</th>
<th colspan="2" rowspan="1">Estados</th>
</tr>
{section name=numero loop=$servicio}
{strip}
<tr bgcolor="{cycle values='#FFFFFF,#DFF4D2'}">
<td>{$servicio[numero].servicio_area}</td>
<td>{$servicio[numero].servicio_servicio}</td>
<td>{$servicio[numero].servicio_aplicacion}</td>
<td>{$servicio[numero].servicio_aplicacion}</td>
<td><a href="index.php?op=udt&act=estados_udt&id={$servic io[numero].servicio_id}">{$servicio[numero].img1|align:c}</a></td>
<td><input type="checkbox" value="1" name="servicio_estado" id="servicio_estado"/></td>
<td><itemIcon="images/menu_panel.gif"><a href="index.php?op=udt&act=cambiar_estados_udt&id= {$servicio[numero].servicio_id}">OK</a></td>
<td><itemIcon="images/menu_panel.gif"><a href="index.php?op=udt&act=estados_udt&id={$servic io[numero].servicio_id}">NO OK</a></td>

</tr>
{/strip}
{/section}

</table>
</form>





Y este es el codigo php que quiero que reciba el valor del checkbox:


<?php

/**
* @author 12345
* @copyright 2010
*/


$result=db_query("select * from servicio where servicio_area='UDT'");

while ($line=mysql_fetch_array($result,MYSQL_ASSOC))
{
$arr=array("img1" => "<img src='images/".$imagenes[rand(3,3)]."'>","img2" => "<img src='images/".$imagenes[rand(3,3)]."'>","img3" => "<img src='images/".$imagenes[rand(3,3)]."'>","img4" => "<img src='images/".$imagenes[rand(3,3)]."'>");
//$result2=db_query("select count(*) as total from inscripciones where inscripcion_curso='%s'",array($line['curso_codigo']));
//$line2=mysql_fetch_array($result2,MYSQL_ASSOC);
$smarty->assign("servicio_estado", array("Seleccione..","OK","OK con Observaciones", "No OK"));
$smarty->append("servicio",array_merge($line,$arr));
}

$smarty->assign("plantilla","udt/udt.tpl");






switch ($act)
{





case "cambiar_estados_udt":
//Color Verde
//echo "<br>estoy dentro del caso cambiar_estados_udt";
//echo "<br>case del color verde";
$safesql = new SafeSQL_MySQL;
$query = "select * from servicio where servicio_id='%s'";
$safe_q = &$safesql->query($query, array($_GET['id']));
$result = mysql_query($safe_q, $link) or die("UPS!.".mysql_error());
$line = mysql_fetch_array($result, MYSQL_ASSOC);
// echo "<br>id: " .$line['servicio_id'];


$aux_id = $line['servicio_id'];
$_POST['servicio_estado']=$_POST['servicio_estado'];

//Aca esta la validacion que verifica si llego el valor del checkbox
// He probado contodo con isset, ==, !=, etc.

if ($_POST['servicio_estado']=='1')
echo "<br>CheckBox desactivado";
else
echo "<br>CheckBox activado";

$query= "update servicio set servicio_estado = '2' where servicio_id = '$aux_id'";
$smarty->assign("plantilla","panel.tpl");

$safe_q = $safesql->query($query, $_SESSION['sql_grabar_values']);
$result = mysql_query($safe_q, $link) or die("UPS!." . mysql_error());
$id=mysql_insert_id();
$smarty->assign("plantilla","panel.tpl");
grabar_log("Modificación resolución","");



$smarty->assign("plantilla","panel.tpl");


$smarty->assign("plantilla","panel.tpl");
header("Location: index.php?op=panel");
exit();
break;

Mas abajo vienen mas casos que están funcionando correctamente y se cierra el php