113 lines
4.4 KiB
PHP
113 lines
4.4 KiB
PHP
<?
|
|
if ( isset( $ins ) && $user_auth && $user_level <= -1 )
|
|
{
|
|
$res = mysql_query( "INSERT INTO encuestas (fecha, validaHasta, pregunta, resp1, resp2, resp3, resp4) VALUES ( CURDATE(), '".addslashes($db_validaHasta)."', '".addslashes($db_pregunta)."', '".addslashes($db_resp1)."', '".addslashes($db_resp2)."', '".addslashes($db_resp3)."', '".addslashes($db_resp4)."')", $conexion ) OR die( "Error<br>".mysql_error($conexion) );
|
|
echo "Su encuesta, ha sido insertada<br><br>";
|
|
}
|
|
if ( isset( $sins ) && $user_auth && $user_level <= -1 )
|
|
{
|
|
echo "<h1>Crear nueva encuesta</h1>";
|
|
?>
|
|
<hr noshade color="#800000">
|
|
<form name="enc" method="POST" action="./?dgo=encuesta.php&ins=1">
|
|
<table border="0">
|
|
<tr>
|
|
<td width="30%">FechaLimite</td>
|
|
<td width="20%"><input type="text" size="6"
|
|
name="db_validaHasta" value="<? echo $db_validaHasta ?>"></td>
|
|
<td valign="top" rowspan="6" width="50%"
|
|
bgcolor="#B4CCE9" class="tdSuave"><strong>Información
|
|
sobre la encuesta</strong><p>Puede especificar una fecha
|
|
limite para la encuesta (AAAA-MM-DD), de forma, que esta tenga una
|
|
caducidad.</p>
|
|
<p>Dispone de un máximo de cuatro respuestas para cada
|
|
encuesta, no tiene porque rellenarlas todas. (Puede que
|
|
su pregunta solo necesite dos respuestas, p.ejem. SI/NO)</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td width="30%">Pregunta<br>
|
|
</td>
|
|
<td width="20%"><input type="text" size="15"
|
|
name="db_pregunta" value="<? echo $db_pregunta ?>"><br>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td width="30%">Respuesta 1</td>
|
|
<td width="20%"><input type="text" size="15"
|
|
name="db_resp1" value="<?echo $db_resp1 ?>"></td>
|
|
</tr>
|
|
<tr>
|
|
<td width="30%">Respuesta 2</td>
|
|
<td width="20%"><input type="text" size="15"
|
|
name="db_resp2" value="<?echo $db_resp2 ?>"></td>
|
|
</tr>
|
|
<tr>
|
|
<td width="30%">Respuesta 3</td>
|
|
<td width="20%"><input type="text" size="15"
|
|
name="db_resp3" value="<?echo $db_resp3 ?>"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Respuesta 4</td>
|
|
<td><input type="text" size="15"
|
|
name="db_resp4" value="<?echo $db_resp4 ?>"></td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr><td align="center" colspan="2"><center><input type="submit" name="B1" value="Enviar"></center>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
<hr noshade color="#800000"></form>
|
|
<?
|
|
} else {
|
|
if ( isset($vota) )
|
|
{
|
|
$res = mysql_query( "SELECT uip FROM encuestas WHERE id=$eid", $conexion );
|
|
$numrows = mysql_num_rows( $res );
|
|
if ( $numrows > 0 )
|
|
{
|
|
$datos = mysql_fetch_array($res);
|
|
// Insertamos la votación
|
|
if ( strcmp( $REMOTE_ADDR, $datos[0] ) != 0 )
|
|
{
|
|
$sql_upd = "UPDATE encuestas SET vresp$vota=(vresp$vota+1), uip='$REMOTE_ADDR' WHERE id=$eid";
|
|
$res = mysql_query( $sql_upd, $conexion ) OR die( "$sql_upd<br><br>".mysql_error($conexion) );
|
|
}
|
|
} else {
|
|
echo "NO ENCUENTRO ESA ENCUESTA EN EL SISTEMA<br><br>";
|
|
}
|
|
}
|
|
|
|
$res = mysql_query( "SELECT id, pregunta, resp1, vresp1, resp2, vresp2, resp3, vresp3, resp4, vresp4 FROM encuestas ORDER BY fecha+id DESC LIMIT 0, 1", $conexion );
|
|
$numrows = mysql_num_rows( $res );
|
|
if ( $numrows > 0 )
|
|
{
|
|
$datos = mysql_fetch_array($res);
|
|
|
|
echo "<h1>Recuento de la encuesta</h1><br>";
|
|
echo "<table class=td_estilos><tr><td><p class=lmenuo><b>La pregunta era:</b></p>";
|
|
echo "$datos[1]<br><br>";
|
|
|
|
$totalVotos = ($datos[3]+$datos[5]+$datos[7]+$datos[9] );
|
|
|
|
$preBar = '<img src="images/stat/bar_left.gif"><img src="images/stat/bar_middle.gif" height="16" width="';
|
|
$postBar = '"><img src="images/stat/bar_right.gif">';
|
|
|
|
if ( !empty( $datos[2] ) )
|
|
echo "1.- ".stripslashes($datos[2])."<br>$preBar".(($datos[3]*300) / $totalVotos )."$postBar $datos[3] Votos<br><br>";
|
|
if ( !empty( $datos[4] ) )
|
|
echo "2.- ".stripslashes($datos[4])."<br>$preBar".(($datos[5]*300) / $totalVotos )."$postBar $datos[5] Votos<br><br>";
|
|
if ( !empty( $datos[6] ) )
|
|
echo "3.- ".stripslashes($datos[6])."<br>$preBar".(($datos[7]*300) / $totalVotos )."$postBar $datos[7] Votos<br><br>";
|
|
if ( !empty( $datos[8] ) )
|
|
echo "4.- ".stripslashes($datos[8])."<br>$preBar".(($datos[9]*300) / $totalVotos )."$postBar $datos[9] Votos<br><br>";
|
|
|
|
echo "Total VOTOS: " . $totalVotos;
|
|
|
|
echo "</td></tr></table>";
|
|
|
|
} else {
|
|
echo "No se encontraron encuestas en el sistema";
|
|
}
|
|
}
|
|
?>
|