Resultado de Enquete abrir em Pop-Up
Olá!
Tenho o sistema de popup abaixo só que qd a pessoa vota, ele abre o resultado na mesma pagina.
Gostaria que ao clicar em votar abrisse uma janelinha pop-up com o resultado.
E aproveitando... como que eu coloco ao laodo do submit votar um botao q mostre direto o resultado da votação?
Obrigado!
Vou colocar os códigos q acho q vao precisar pra me ajudar:
index.php
<?php
include("conexao.php");
$busca = mysql_query("SELECT * FROM enquete order by id desc");
$linha = mysql_fetch_array($busca);
echo "<form action='security/enquete/calcula.php' method='post'>";
echo "<b>{$linha['pergunta']}</b><br>";
echo "<input type='radio' name='opcao' value='opcao01'>{$linha['opcao01']}<br>";
echo "<input type='radio' name='opcao' value='opcao02'>{$linha['opcao02']}<br>";
if ($linha['opcao03'] != '')
{
echo "<input type='radio' name='opcao' value='opcao03'>{$linha['opcao03']}<br><br>";
}
echo "<input type='submit' value='Votar' name='enviar' class='submit' )>";
echo "</form>";
?>
calcula.php
<?php ob_start() ?>
<?php
include_once("../../conexao.php");
if (isset($_POST['enviar']))
{
$opcao = $_POST['opcao'];
if ($opcao!='')
{
$busca = mysql_query("SELECT * FROM enquete order by id desc");
$linha = mysql_fetch_array($busca);
$id = $linha['id'];
$total = $linha['total'];
$total = $total + 1;
mysql_query("UPDATE enquete SET total=$total where id = $id") or die (mysql_error());
$total = $linha['total'];
switch ($opcao)
{
case "opcao01":
$antes = $linha['opcao01_n'];
$total01 = $antes + 1;
mysql_query("UPDATE enquete SET opcao01_n=$total01 where id = $id") or die(mysql_error());
break;
case "opcao02":
$antes = $linha['opcao02_n'];
$total02 = $antes + 1;
mysql_query("UPDATE enquete SET opcao02_n=$total02 where id = $id") or die(mysql_error());
break;
case "opcao03":
$antes = $linha['opcao03_n'];
$total03 = $antes + 1;
mysql_query("UPDATE enquete SET opcao03_n=$total03 where id = $id") or die(mysql_error());
break;
}
header ("Location:resultado.php");
} else {
echo "Escolha uma opção antes de votar!";
header("Location:home.php");
}
}
?>
<?php ob_end_flush() ?>
resultado.php
<?php
echo "<h2>Resultado</h2><br>";
include_once("../../conexao.php");
$busca = mysql_query("SELECT * FROM enquete order by id desc");
$linha = mysql_fetch_array($busca);
$total = $linha['total'];
if ($total !=0)
{
$opcao01 = floor($linha['opcao01_n'] / $total * 100);
$opcao02 = floor($linha['opcao02_n'] / $total * 100);
$opcao03 = floor($linha['opcao03_n'] / $total * 100);
$largura01 = 100 - $opcao01;
}
echo "<div style='position:relative; float:left; height:auto; width:auto; margin:10px; padding:5px; border: 1px solid #CCC; background: url(imagens/stripes_.gif)'>";
echo "<h6 style='text-align:left;'>{$linha['opcao01']}</h6>";
echo "<div style='position:relative; float:left; height:10px; width:{$opcao01}px; background: #ff6600;'></div>";
echo "<p class='empresa'>".$opcao01 . "%</p>";
echo "<h6 style='text-align:left;'>{$linha['opcao02']}</h6>";
echo "<div style='position:relative; float:left; height:10px; width:{$opcao02}px; background:#ff6600;'></div>";
echo "<p class='empresa'>".$opcao02 . "%</p>";
if ($linha['opcao03'] != ''){
echo "<h6 style='text-align:left;'>{$linha['opcao03']}</h6>";
echo "<div style='position:relative; float:left; height:10px; width:{$opcao03}px; background:#ff6600;'></div>";
echo "<p class='empresa'>".$opcao03 . "%</p>";
}
echo "<br><p>Total de votos: ".$total."</p>";
echo "</div>";
echo "<p><a href=\"java script:history.go(-1)\">Voltar</a></p>";
?>Discussão (12)
Carregando comentários...