before anything else, the code below was not made by me..
i just copied it and add some syntax to suit my needs..
unfortunately, i can't able to execute or run the code properly.. i know there's a bit wrong coding in my code. 🙂
anyway, what i am trying to do is..
if the Status is set to 1 , then, the user will see a VOTE NOW button..
other wise, if the status is set to 2, the user will no longer see or access the VOTE NOW button...
<?php
require 'config.php';
?>
<?php
$status = 0;
$query="SELECT * FROM stat WHERE status='$status'";
$result=mysql_query($query);
mysql_close();
$row = mysql_fetch_array( $result );
$chckstat = $status;
if ($chckstat == "1") {
echo "<form action='<?=$_SERVER['PHP_SELF'];?>' method='post'>";
echo "<input type='submit' name='submit' value='VOTE NOW'></form>";
$id = (int)$_GET['id'];
if($_POST['submit']=='VOTE NOW')
{
$timeout=10; //60*60*24 seconds = 1 day
$time=time();
$out=$time-$timeout;
$ip=$_SERVER['REMOTE_ADDR'];
$check_double=mysql_query("SELECT * FROM ips WHERE ip='$ip' AND time>$out")or die(mysql_error());
if(mysql_num_rows($check_double)>0){
echo "Sorry, you've already voted. try again after 10 seconds.";
}
else{
echo "Thank you";
$reqonce=mysql_query("INSERT INTO ips(ip,time) VALUES('$ip','$time')");
//$query = mysql_query(" UPDATE `tz_members` SET point = point + 1 WHERE id = $id;") or die(mysql_error());
}
}
}
else if ($chckstat == "2") {
echo "Sorry, Voting is closed. ";
}
?>
any help will be much appreciated..
Thank you 🙂