Website E-Voting Untuk Pemilihan Wanita Tercantik




source code = index.php

<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="utf-8">
<meta name = "format-detection" content = "telephone=no" />
<link rel="icon" href="images/favicon.ico">
<link rel="shortcut icon" href="images/favicon.ico" />
<link rel="stylesheet" href="css/animation.css">
<link rel="stylesheet" href="css/camera.css">
<link rel="stylesheet" href="css/contact-form.css">
<link rel="stylesheet" href="css/touchTouch.css">
<link rel="stylesheet" href="css/style.css">
  <script src='//maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false'></script>
<script src="js/jquery.js"></script>
<script src="js/jquery-migrate-1.1.1.js"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/script.js"></script>
<script src="js/jquery.ui.totop.js"></script>
<script src="js/touchTouch.jquery.js"></script>
<script src="js/isotope.pkgd.js"></script>
<script src="js/TMForm.js"></script>
<script src="js/modal.js"></script>
<script src="js/camera.js"></script>
<!--[if (gt IE 9)|!(IE)]><!-->
<script src="js/jquery.mobile.customized.min.js"></script>
<!--<![endif]-->
<script>
 $(window).load(function(){
  $().UItoTop({ easingType: 'easeOutQuart' });
  $('.gallery .gall_item').touchTouch();
 });
 $(document).ready(function(){
     jQuery('#camera_wrap').camera({
      loader: false,
      pagination: true ,
      minHeight: '500',
      thumbnails: false,
      height: '44.42708333333333%',
      caption: true,
      navigation: false,
      fx: 'mosaic'
    });
    $('.gallery .gall-item').touchTouch();
  });
</script>
<!--[if lt IE 8]>
 <div style=' clear: both; text-align:center; position: relative;'>
   <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode">
     <img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." />
   </a>
</div>
<![endif]-->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<link rel="stylesheet" media="screen" href="css/ie.css">
<![endif]-->
</head>
<body>
<div class="texture">
<!--==============================
              header
=================================-->
<header id="home" class="page">
  <div class="navigation single-page-nav">
    <div class="container_12">
      <div class="grid_12">
        <h1 class="logo">
          <a href="index.html">BEAUTY VOTE</a>
        </h1>
        <nav>
          <ul>
           <li><a href="index.html" class="current">Home</a></li>
           <li><a href="Vote.php">Mulai Vote</a></li>
         </ul>
        </nav>
      </div>
    </div>
  </div>
  <div id="camera_wrap">
    <div data-src="images/Yoona.jpg">
      <div class="caption fadeIn">Kamu yakin cantik? <span class="bull"></span> Imut?  <span class="bull"></span> Gemesin ?</div>
    </div>
    <div data-src="images/cewe1.jpg">
      <div class="caption fadeIn">Buktiin Yuk</div>
    </div>
    <div data-src="images/cewe2.jpg">
      <div class="caption fadeIn">Kita Vote Disini</div>
    </div>
  </div>
</header>
<embed src="sound/welcome.mp3" controller="true" autoplay="true" autostart="True" width="0" height="0" />
</html>

Tampilan Utama
Berisi tentang menu utama yaitu menu voting source code = vote.php
<?php
//koneksi database
require'config.php';
require'vote-count.php';
require'functions.php';
?>

<title>Sistem Vote</title>
<link rel="stylesheet" href=="style.css">
</body>
<body>
<div class="vote-container">
<table>
<tr>
<th colspan="2">Cantik Yang Mana ?</th>
</tr>
<tr>
<?php
$sql = "SELECT*FROM vote_opsi";
$query=$connect->query($sql);

while ($row = $query->fetch_assoc()):?>
<td>
<div class="presentase"><?php echo getpolling($row['id_opsi']);?></div>
<a href="vote-count.php?nomer=<?php echo $row['id_opsi'];?>">
<img src="<?php echo $row['thumbnail'];?>" width="150" alt=""/>
<p><?php echo $row['nama_opsi'];?></p>
</a>
</td>
<?php endwhile;?>

</tr>
</table>
</div>
</body>
<?php include('embed.php'); ?>
</html>

source code koneksi Berisi tentang kode koneksi ke database = config.php
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'votes';

$connect = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

if ($connect->connect_error) {
die('Error Koneksi:' .$connect->connect_error);
}
?>

Untuk memasukan voting ke database source code = vote-count.php
<?php
require_once 'config.php';
if (isset($_GET['nomer']) && ! empty($_GET['nomer'])) {
 
    $nomerVote = $_GET['nomer'];
    // sql untuk menambahkan vote kedatabase
    $sql = "INSERT INTO voting (id_opsi, date_create) VALUES ('$nomerVote', NOW()) ";

    $insert = $connect->query($sql);
    if ($insert) {
        echo "<script>alert('Terima Kasih atas Vote nya'); window.location.href='vote.php';</script>";
        exit();
    } else {
        die('Oops!! Internal Error');
    }
}

Untuk membuat fungsi perhitungan hasil vote
Perhitungan voting dilakukan dengan rumus hasil=(a/n)*100;
a : total suara vote dari satu pilihan
n : total suara vote dari seluruh pilihan
hasil : hasil bagi a dan n dikali 100,yang nantinya dinyatakan persen (%)

kita buat source code = functions.php
<?php
/**
 * getPolling adalah fungsi untuk mengambil dan menambilkan 
 * poling atau hasil vote yang diperoleh, sekaligus di convert 
 * kedalam persen
 * 
 * @param  int $id id_opsi
 * @return string
 */
function getPolling($id)
{
    global $connect;

    // sql untuk mengambil semua data;
    $sql = "SELECT * FROM voting";
    $query = $connect->query($sql);
    
    // total seluruh voting
    $totalVote = $query->num_rows;
    $query->close();

    // sql untuk mengabil data yang spesifik (sesuai $id) 
    $sqlSpesifik = "SELECT * FROM voting WHERE id_opsi = '$id'";
    $querySpesifik = $connect->query($sqlSpesifik);
    
    // total voting dari $id (satu opsi)
    $voteOpsi = $querySpesifik->num_rows;
    $querySpesifik->close();

    $hitungVote = '';
    // $totalVote Tidak boleh 0;
    if ($totalVote) {
        // round() adalah fungsi pembulatan
        $hitungVote = round( ($voteOpsi/$totalVote) * 100 );
    }

    return  empty($hitungVote) ?  '0%' : $hitungVote . '%'; 
}


DATABASE E-VOTING = VOTES

Didalam database ini saya hanya menggunakan 2 table yaitu =
  • vote_opsi
  • voting 
tabel vote_opsi =

tabel voting =



Nama : Aldi Ahmad Hakiki
Kelas : TI-VIDK
NIM : A2.1400013
0 Komentar untuk "Website E-Voting Untuk Pemilihan Wanita Tercantik"

Silakan tinggalkan komentar anda. DILARANG KERAS menyimpan link blog/web pada komentar dengan tujuan backlink, Spam.

 
Copyright © 2014 Tutorial Kampus - All Rights Reserved
Template By. Catatan Info