Ver Mensaje Individual
  #3 (permalink)  
Antiguo 22/07/2010, 14:31
turfeano
 
Fecha de Ingreso: diciembre-2008
Mensajes: 190
Antigüedad: 15 años, 4 meses
Puntos: 6
Respuesta: Boton Submit toma valor NULL y no deja compararlo con su valor original

Con respeto, te modifique partes,porq me pareces q estas equivocado como pasas el id para aceptar el voto

Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <?php
  5. $link = mysql_connect('localhost', 'root', 'yo2bik');
  6. if (!$link)
  7.    die('Error al conectarse con MySQL: ' . mysql_error().' <br>Número del error: '.mysql_errno());
  8. if (! @mysql_select_db("pintatumundoagatha",$link)){
  9.    echo "No se pudo conectar correctamente con la Base de datos";
  10.    exit();
  11. }
  12. ?>
  13.  
  14. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  15. <title>Documento sin t&iacute;tulo</title>
  16. </head>
  17.  
  18. <body>
  19.  
  20.    <br />
  21.    <form id="busca_imagenes" name="busca_imagenes" method="post" action="">
  22.    <fieldset>
  23.   <table width="200" border="0" align="center">
  24.       <tr>
  25.         <td>Nombre Artista</td>
  26.         <td><input type="text" name="nombre_artista" id="nombre_artista" /></td>
  27.         <td>&nbsp;</td>
  28.       </tr>
  29.       <tr>
  30.         <td>Colegio</td>
  31.         <td><label for="colegio_artista"></label>
  32.           <input type="text" name="colegio_artista" id="colegio_artista" /></td>
  33.         <td><input type="submit" name="Buscar" id="Buscar" value="Buscar" /></td>
  34.       </tr>
  35.       <tr>
  36.         <td>Curso</td>
  37.         <td><label for="curso_artista"></label>
  38.           <input type="text" name="curso_artista" id="curso_artista" /></td>
  39.         <td>&nbsp;</td>
  40.       </tr>
  41.   </table>
  42.   </fieldset>
  43. </form>
  44.  
  45. <?php
  46.  
  47. if ($_POST['Buscar'])
  48. {
  49.      
  50.         if ($_POST['nombre_artista'])
  51.     {
  52.         $buscar_nombre_artista="select artista.*, pinturas.* from artista, pinturas where artista.id_artista=pinturas.id_artista and artista.nombre_artista='".$_POST['nombre_artista']."' and pinturas.id_artista=artista.id_artista";
  53.          
  54.         $buscar_nombre_artista = mysql_query($buscar_nombre_artista) or die(mysql_error());
  55.                 while($row=mysql_fetch_assoc($buscar_nombre_artista))
  56.                 {
  57.                     echo "<form id='imagenes' name='imagenes' method='post' action=''>";
  58.                     echo '<center><img src="'.$row['PINTURA_URL'].'"></img></center>';
  59.                     echo '<center>Nombre: '.$row['NOMBRE_ARTISTA'].'</center>';
  60.                     echo '<center>Curso: '.$row['CURSO_ARTISTA'].'</center>';
  61.                     echo '<center>Colegio: '.$row['COLEGIO_ARTISTA'].'</center>';
  62.                     //echo "<center><input type='Submit' name='Algo' value='Algo' /></center>";
  63.                     ?>
  64.                    
  65. <center> <input type="hidden" name="idpintura" value="<?php echo $row['ID_PINTURA'];?>"/></center>
  66. <center> <input type="submit" name="Votar" value="Votar"/></center>
  67.                     <?php
  68.                     echo "</form>";
  69.  
  70.                 }
  71.                                                
  72.     }
  73.  
  74.   }              
  75.                  if(($_POST['Votar'])=="Votar")
  76.                 {
  77.                     //header('Location: res.php');
  78.                     ?>
  79. <SCRIPT LANGUAGE="javascript">
  80.        alert('Gracias por Votar');
  81.                                                      
  82.    </SCRIPT>
  83.     <?php
  84.                      
  85.                     $votos = $votos + 1;
  86. // actualizo la base de datos
  87.  
  88.    $consulta = "UPDATE votacion SET voto = voto +1 WHERE id_pintura=".mysql_real_escape_string($_POST['idpintura']);  
  89.     mysql_query($consulta,$link);
  90.  
  91.                
  92.          
  93.     }
  94.      
  95.      
  96.  
  97. ?>
  98.  
  99. </body>
  100. </html>

Última edición por turfeano; 22/07/2010 a las 14:40