Facebook

Online Voting System

Online Voting System

Online Voting System in php using mysqli query the function of this online voting system is that there are three cricket players SHAHID AFRIDI,VIRAT KOHLI and GAYLE the user can be visit the online voting system and cast vote his favorite player after casting vote he cannot vote again because we are using COOKIES  to protect the again and again voting of users
&al;?php

Online Voting System
Css File
.main{
width: 600px;
height: 200px;
background-color: #2F4F4F;

margin: 0 auto;
}
.form_m{
text-align: center;
padding-top: 20px;
}
.form_m input[type="submit"]
{
width: 100px;
height: 40px;
border-radius: 5px;
background-color: #99FF33;
font-weight: bolder;
border:0;
opacity: 0.6;
}
.form_m input[type="submit"]:hover{
box-shadow: inset 0 -4px rgba(0,0,0,0.4);
opacity: 1;
}

.all{
width: 600px;
margin: 0;
height: 150px;
margin: 0 auto;

margin-top: 10px;

}
.all img{
width:150px;
height: 100px;
margin-top: 20px;
margin-left: 20px;
border-radius: 100%;
box-shadow: inset 3px 3px rgba(0,0,0,0.4)
float: left;
box-shadow: 6px 6px rgba(0,0,0,0.4);


}
.all h3{

float: right;
margin-top: 60px;
margin-right: 100px;
color:white;
}
.aa{
width: 600px;
height: 800px;
background-color: #8FBC8F;
margin: 0 auto;
}
body{
margin: 0;
padding: 0;

}

PHP File



<!DOCTYPE html>
<html>
<head>
<title>Online Voting System</title>
<link rel="stylesheet" type="text/css" href="css/design.css">
<div class="aa">
</head>
<body>
<div class="main">
<div class="form_m">
<h2 style='color:white;'>Players Voting System</h2>
<form method="post" action="">
<input type="submit" name="shahid" value="AFRIDI">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="kohli" value="KOHLI">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="gayle" value="GAYLE">&nbsp;&nbsp;&nbsp;&nbsp;
</form>
</div>
</div>
</body>
</html>
<?php
include 'connection.php';
if(isset($_COOKIE['vote'])) 
{
    echo "<h2 style='text-align:center;color:red;'>Can\'t vote again</h2>";
}
         else{

//first portion
        if(isset($_POST['shahid']))
{
   setcookie('vote', true,  time() + (10 * 365 * 24 * 60 * 60), "/");
   $shahid=mysqli_query($con,"UPDATE players SET shahid=shahid+1");
   if($shahid)
{
echo "<h3 style='margin-left:30px;'>You Are Cast Vote For Shahid Afridi.. </h3>";
$select_q=mysqli_query($con,"SELECT * FROM players");
while($run=mysqli_fetch_array($select_q))
{
$per_a=$run['shahid'];
$per_v=$run['kohli'];
$per_g=$run['gayle'];
$count=$per_a+$per_v+$per_g;
   $per_player=round($per_a*100/$count).'%';
  
}
}
}
//second portion
          if(isset($_POST['kohli']))
{
     setcookie('vote', true,  time() + (10 * 365 * 24 * 60 * 60), "/");
     $kohli=mysqli_query($con,"UPDATE players SET kohli=kohli+1");
     if($kohli)
{
 echo "<h3 style='margin-left:30px;'>You Are Cast Vote For Virat Kohli..</h3>";
 $select_q=mysqli_query($con,"SELECT * FROM players");
 while($run=mysqli_fetch_array($select_q))
{
$per_a=$run['shahid'];
$per_v=$run['kohli'];
$per_g=$run['gayle'];
$count=$per_a+$per_v+$per_g;
   $per_player=round($per_v*100/$count).'%';
   
}
}
}
//third portion
          if(isset($_POST['gayle']))
{
    setcookie('vote', true,  time() + (10 * 365 * 24 * 60 * 60), "/");
    $gayle=mysqli_query($con,"UPDATE players SET gayle=gayle+1");
    if($gayle)
{
echo "<h3 style='margin-left:30px;'>You Are Cast Vote For Gayle..</h3>";
$select_q=mysqli_query($con,"SELECT * FROM players");
while($run=mysqli_fetch_array($select_q))
{
$per_a=$run['shahid'];
$per_v=$run['kohli'];
$per_g=$run['gayle'];
$count=$per_a+$per_g+$per_g;
   $per_player=round($per_g*100/$count).'%';
   
}
}

}}
?>
<?php
include 'detail.php';
?>
</div>
Good luck 


Online Voting System Online Voting System Reviewed by Shakil Khan on 02:52 Rating: 5

No comments:

Thanks for your feedback...

Useful Information

Powered by Blogger.