Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/09/2011, 21:10
Avatar de morfasto
morfasto
 
Fecha de Ingreso: julio-2011
Ubicación: Lima
Mensajes: 291
Antigüedad: 12 años, 9 meses
Puntos: 8
Respuesta: Checkbox con PHP

Ya resolvi el problema:

Código PHP:
Ver original
  1. <?phpfunction conectarse($host,$usuario,$password,$BBDD){
  2.    $link=mysql_connect($host,$usuario,$password) or die (mysql_error());
  3.    mysql_select_db($BBDD,$link) or die (mysql_error());
  4.    return $link;
  5. }
  6. $link=conectarse("localhost","usuario","contraseña","base_datos");  
  7.  
  8. $sql = "select * from clientes, cliente_opciones where clientes.cliente_id = '$_SESSION[cliente]' and cliente_opciones.cliente_id ='$_SESSION[cliente]' ";
  9. $sql = mysql_query($sql, $link);
  10.  
  11.     while($rs=mysql_fetch_array($sql))
  12.           { ?>
  13.                     <h1>Informacion Personal:</h1>
  14.                     <form action='configurar.php' method='post'>
  15.                     <table border='1'>
  16.                         <tr>
  17.                             <td></td>
  18.                             <td></td>
  19.                             <td>Ocultar</td>
  20.                         </tr>
  21.                         <tr>
  22.                             <td>Nombre:</td>
  23.                             <td><input name='nombre' type='text' maxlength='25' value='<?php echo $rs['nombre']; ?> '/></td>
  24.                             <td align="center"><input name="o_nombre" type="checkbox" value="1" <?php if($rs['o_nombre']==1){echo "checked";} ?>></td>
  25.                         </tr>
  26.                         <tr>
  27.                             <td>Apellido:</td>
  28.                             <td><input name='apellido' type='text' maxlength='25' value='<?php echo $rs['apellido']; ?>'/></td>
  29.                             <td align="center"><input name="o_apellido" type="checkbox" value="1" <?php if($rs['o_apellido']==1){echo "checked";} ?>></td>
  30.                         </tr>
  31.                     </table>
  32.                         <input name='Registrar' type='submit' value='Guardar'/>
  33.                     </form>
  34.     <?php } ?>

Código PHP:
Ver original
  1. <?php
  2.  
  3. $con1 = mysql_connect("localhost","usuario","contraseña");
  4. if (!$con1)
  5.   {
  6.   die('Could not connect: ' . mysql_error());
  7.   }
  8.  
  9. mysql_select_db("base_datos", $con1);
  10.  
  11. $sql1="UPDATE clientes SET nombre = '$_POST[nombre]', apellido = '$_POST[apellido]' where usuario_id =  '$_SESSION[usuario]'";
  12. $sql1="UPDATE opciones SET o_nombre = '$_POST[o_nombre]', o_apellido = '$_POST[o_apellido]' where usuario_id =  '$_SESSION[usuario]'";
  13.  
  14. if (!mysql_query($sql1,$con1))
  15.   {
  16.   die('Error: ' . mysql_error());
  17.   }
  18.  
  19. mysql_close($con1);
  20. header ("Location: info_personal.php");
  21. ?>