Location: PHPKode > projects > SSEP - Election Simulation System > ssep-0.2/eleger.php
<?

session_start();

require("conf.php");

$ip;

# POST
if($_SERVER['REQUEST_METHOD'] != 'POST')
exit("</script><meta http-equiv=refresh content='0;url=".$path."/'>");

if($sql || $query || $sql2 || $query2)
exit("<script language=JavaScript>alert(\"Error: you can not set vars tought URL\");history.go(-1);</script>");

# Verificacao de Existencia
if(!$codigo)
exit("<script language=JavaScript>alert(\"Error: You need to fill with yout id.\");history.go(-1);</script>");

# Verifica tipo digitado no codigo
if(!ereg('[0-9]', $codigo))
exit("<script language=JavaScript>alert(\"Error: ID must have only numbers.. \");history.go(-1);</script>");


# Verifica tamanho do codigo
if(strlen($codigo) != 8)
exit("<script language=JavaScript>alert(\"Error: ID must have only 8-digit numbers.\");history.go(-1);</script>");

$sql="select id,candidate from people where id='$codigo'";
$query=mysql_db_query($db,$sql,$conn);
$row=mysql_fetch_array($query);
if(!$row)
exit("<script language=JavaScript>alert(\"Error: Your ID does not existis in your database.\");history.go(-1);</script>");
if($row[candidato] != 0)
exit("<script language=JavaScript>alert(\"Error: You can only vote a single time.\");history.go(-1);</script>");
$sqlip="select ip from people where ip = '$ip' ";
$queryip=mysql_db_query($db,$sqlip,$conn);
if(mysql_num_rows($queryip) > 1)
exit("<script language=JavaScript>alert(\"Error: You can only vote once per machine.\");history.go(-1);</script>");


session_register('letsafe');
session_register('id');
$id=$codigo;
$letsafe=$keyword;

mysql_close($conn);

exit("<meta http-equiv=Refresh content='0; url=".$path."/eleger2.php'>");


?>
Return current item: SSEP - Election Simulation System