Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/11/2007, 05:38
Avatar de hernansam
hernansam
 
Fecha de Ingreso: septiembre-2007
Ubicación: Funes , Argentina
Mensajes: 204
Antigüedad: 16 años, 7 meses
Puntos: 0
problema con cookie en encuesta

Hola tengo un problema con la cookie que le puse a una encuesta ante la cookie funcionaba pero ahora que cambie la encuesta no me funciona mas.
encuesta

Código PHP:
    if($_POST['encuestaOK']==and !isset($_COOKIE['encuesta'])){
        
setcookie("encuesta"1time()+21600);
    } 
<form action="encuesta1/resultados.php" method="post" target = "ventanita" />
¿Quien gana las elecciones en Rosario Central?<br>

<input type=radio name="respuesta" Value="1"> Settimini<br>
<input type=radio name="respuesta" Value="2"> Usandizaga <br>
<input type=radio name="respuesta" Value="3"> Joaquin<br>
<input type="submit" value="Votar" onclick="ventanita = window.open('about:blank','ventanita','width = 300,height = 300')">
</form>

resultados
Código PHP:
<?php
if(isset($_COOKIE['encuesta'])){
    
    echo 
"Ud.ya voto";
    
    }else{
        
         
    

        
error_reporting(2048);
$f=fopen("encuesta.txt","r");
if(
$f){echo "";}
else{echo 
"No puedo abrir f";}
$todas=fread($f,filesize("encuesta.txt"));
$respuestas=explode(",",$todas);
fclose($f);

if (
$respuesta) {

$respuestas[$respuesta-1]++;
$f=fopen("encuesta.txt","w");

$todas=$respuestas[0].",".$respuestas[1].",".$respuestas[2];
fwrite($f,$todas,strlen($todas));
fclose($f);
}

$total=$respuestas[0]+$respuestas[1]+$respuestas[2];
if(
$total==0) {
$porcentaje[0]=0;
$porcentaje[1]=0;
$porcentaje[2]=0;
} else {
$porcentaje[0]=sprintf("%1.2f",(($respuestas[0]/$total)*100));
$porcentaje[1]=sprintf("%1.2f",(($respuestas[1]/$total)*100));
$porcentaje[2]=sprintf("%1.2f",(($respuestas[2]/$total)*100));
}



?>


</div>
<table border="0" align="center">
<tr>
<td colspan="3" align="center">
¿Quien gana las elecciones en Rosario Central?
</td>
</tr>
<tr>
<td align="left">
<?php echo "$porcentaje[0]%"; ?>
</td>
<td align="left">
<img src="red.png" height="15" width="<?php echo "$porcentaje[0]"; ?>">
</td>
<td>
Settimini
</td>
</tr>
<tr>
<td align="left">
<?php echo "$porcentaje[1]%"; ?>
</td>
<td align="left">
<img src="blue.png" height="15" width="<?php echo "$porcentaje[1]"; ?>">
</td>
<td>
Usandizaga
</td>
</tr>
<tr>
<td align="left">
<?php echo "$porcentaje[2]%"; ?>
</td>
<td align="left">
<img src="yellow.png" height="15" width="<?php echo "$porcentaje[2]"; ?>">
</td>
<td>
Joaquin
</td>
</tr>
</table>
<div align="center"><br>
</div>
<div align="center"><strong></strong></div>
<div align="center"><strong>Hernansam.com</strong>
Código PHP: