/    Sign up×
Community /Pin to ProfileBookmark

Vote once with Status: ON / OFF feature

Good day,
im using this code posted somewhere on other forum,.

[code=php]<?php
mysql_connect(“localhost”, “root”, “password”);
mysql_select_db(“webcodez”);
?>
<form action=”<?=$_SERVER[‘PHP_SELF’];?>” method=”post”>
<input type=”submit” name=”submit” value=”dai to4ka” class=”bt_register” />
</form>
<?php
$id = (int)$_GET[‘id’];
if($_POST[‘submit’]==’dai to4ka’)
{
$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 “one time pls “;
}
else{
echo “success”;
$vote=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());
}

}[/code]

It works fine, but i want to add a STATUS: ON / OFF

if the status is ON then the user can vote..
otherwise, if status is OFF, the user can’t vote at all + error message saying “Voting is off, you can’t vote at this moment”

btw, changing of status can only be access by the admin side..
Thank you so much..

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @v3inTe spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...