hola foreros del web tengo un problema con mi pagina estoy haciendo un trabajo de la universidad la pag. tiene un carrito de compras pero quiero habilitar un boton de formulario solo cuando se cumplan dos condiciones:
1) que el usuario haya iniciado sesion
2) que haya articulos en el carrito
El boton ya esta deshabilitado me disculpan si algo esta mal redactado es que estoy nuevo hehehe...bueno igual no se como hacer lo del boton ahhh dentro del codigo el boton se llama comprar
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
les dejo el codigo....
codigo del carrito: Código PHP:
<?
session_start();
if(isset($_SESSION['carrito']) || isset($_POST['nombre_real'])){
if(isset($_SESSION['carrito'])){
$carrito_mio=$_SESSION['carrito'];
if(isset($_POST['nombre_real'])){
$nombre_real=$_POST['nombre_real'];
$precio=$_POST['precio'];
$cantidad=$_POST['cantidad'];
$donde=-1;
for($i=0;$i<=count($carrito_mio)-1;$i ++){
if($nombre_real==$carrito_mio[$i]['nombre_real']){
$donde=$i;
}
}
if($donde != -1){
$cuanto=$carrito_mio[$donde]['cantidad'] + $cantidad;
$carrito_mio[$donde]=array("nombre_real"=>$nombre_real, "precio"=>$precio,"cantidad"=>$cuanto);
}else{
$carrito_mio[]=array("nombre_real"=>$nombre_real, "precio"=>$precio,"cantidad"=>$cantidad);
}
}
}else{
$nombre_real=$_POST['nombre_real'];
$precio=$_POST['precio'];
$cantidad=$_POST['cantidad'];
$carrito_mio[]=array("nombre_real"=>$nombre_real, "precio"=>$precio,"cantidad"=>$cantidad);
}
if(isset($_POST['cantidad2'])){
$id=$_POST['id'];
$cuantos=$_POST['cantidad2'];
if($cuantos<1){
$carrito_mio[$id]=NULL;
}else{
$carrito_mio[$id]['cantidad']=$cuantos;
}
}
if(isset($_POST['id2'])){
$id=$_POST['id2'];
$carrito_mio[$id]=NULL;
}
$_SESSION['carrito']=$carrito_mio;
}
?>
[B]inicio de sesion del usuario:[/B]
<?php
echo 'Bienvenido, ';
if (isset($_SESSION['k_username'])) {
echo $_SESSION['k_username'];
echo '<a href="logout.php">Logout</a>';
}else{
echo '<a href="login.php">Ingresar</a> <a href="registro.php">Registrarse</a>';
}
?>
[B]esta es la otra parte del codigo del carrito:[/B]
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="238" bgcolor="#5A8C4F"><span class="Estilo1"><strong>Nombre</strong></span></td>
<td width="127" align="right" bgcolor="#5A8C4F"><span class="Estilo1"><strong>Precio</strong></span></td>
<td width="122" align="center" bgcolor="#5A8C4F"><span class="Estilo1"><strong>Cantidad</strong></span></td>
<td width="80" align="right" bgcolor="#5A8C4F"><span class="Estilo1"><strong>Total</strong></span></td>
<td width="33" align="center" bgcolor="#5A8C4F"><span class="Estilo1"></span></td>
</tr>
<?
if(isset($_SESSION['carrito'])){
$total=0;
for($i=0;$i<=count($carrito_mio)-1;$i ++){
if($carrito_mio[$i]!=NULL){
?>
<tr>
<td valign="top" bgcolor="#B5D1A8"><span class="Estilo1"><? print $carrito_mio[$i]['nombre_real']; ?></span></td>
<td align="right" valign="top" bgcolor="#B5D1A8"><span class="Estilo1"><? print $carrito_mio[$i]['precio']; ?></span></td>
<td align="center" valign="top" bgcolor="#B5D1A8">
<form action="" method="post" name="form1" class="Estilo1" id="form1">
<label>
<input name="id" type="hidden" id="id" value="<? print $i; ?>" />
<input name="cantidad2" type="text" id="cantidad2" value="<? print $carrito_mio[$i]['cantidad']; ?>" size="2" />
</label>
<label>
<input type="image" name="imageField" src="imagenes/actualizar.gif" />
</label>
</form> </td>
<td align="right" valign="top" bgcolor="#B5D1A8"><span class="Estilo1"><? print $carrito_mio[$i]['precio'] * $carrito_mio[$i]['cantidad']; ?></span></td>
<td align="center" valign="top" bgcolor="#B5D1A8"><form action="" method="post" name="form2" class="Estilo1" id="form2">
<input name="id2" type="hidden" id="id2" value="<? print $i; ?>" />
<label>
<input type="image" name="imageField2" src="imagenes/cart_remove.png" />
</label>
</form> </td>
</tr>
<?
$total=$total + ($carrito_mio[$i]['precio'] * $carrito_mio[$i]['cantidad']);
}
}
}
?>
<tr>
<td bgcolor="#B5D1A8"><span class="Estilo1"></span></td>
<td align="right" bgcolor="#B5D1A8"><span class="Estilo1"></span></td>
<td bgcolor="#B5D1A8"><span class="Estilo1"><strong>Total:</strong></span></td>
<td align="right" bgcolor="#B5D1A8"><span class="Estilo1">
<?
if(isset($_SESSION['carrito'])){
print $total ?>
<? } ?>
Bs </span></td>
<td align="center" bgcolor="#B5D1A8"><span class="Estilo1"></span></td>
</tr>
<tr>
<td> </td>
<td align="right"> </td>
<td><form id="comprar" name="comprar" method="post" action="resumen.php">
<label>
<input name="comprar" type="submit" id="comprar" value="Comprar" disabled="true"/> // ESTE ES EL BOTON :'(
</label>
</form></td>
<td align="right"> </td>
<td align="center"> </td>
</tr>
</table>
OK de antemano muchas gracias para aquellos q puedan ayudarme.....