<?php ////////////////////////////// session_start(); $s_id=session_id(); if(!isset($_POST[opt])){echo "<font face='Verdana' size='2' color=red>Please select one option and then submit</font>";} else{ //ADDED by PusHm0v.... $ip_address = $_SERVER['REMOTE_ADDR']; //cek ke tabel ip_vote... $qry=mysql_query("select ip_address from ip_vote where ip='$ip_address'"); // mysql_num_rows akan menghasilkan JUMLAH row/baris dari database yg cocok dengan kriteria WHERE... dalam hal ini mencari ip address yang udah ter record ke database. if (mysql_num_rows($qry)) { echo "IP ADDRESS udah ngelakuin vote..."; exit(); } //kalo gak ada di database baru masukin voting, n jgn lupa INSERT ip address ke tabel ip_vote... $qry=mysql_query("INSERT INTO ip_vote(ip) VALUES ('$ip_address')"); //DONE ADDED by PusHm0v... //ambil data vote yang di pilih //cek berapa jmlh votenya $qry=mysql_query("select vote from data_polling where pilihan='$_POST[opt]'"); $hsl=mysql_fetch_array($qry); $jvot=$hsl[vote]; //jmlvote=hasilvote+1 $jmlvote=$jvot+1; mysql_query("update data_polling set vote='$jmlvote' where pilihan = '$_POST[opt]'"); values('$s_id',$qst_id,'$opt')"); echo mysql_error(); echo "Thanks for your views, Please <a href=view_poll_result.php>click here to view the poll result</a> or click here to visit the <a href=poll_display.php>VIEW PAGE</a>"; } ?>
Minggu, 09 Januari 2011
vote coding php
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar