• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] vote system

Status
Not open for further replies.

Tok124

Respected Member
Hello, I'm trying to figure out how to make a Vote System but i don't really know how it should be done properly.
I can make it so when the player click the vote button he come to the vote link and he also get points in database. But he can click the button how many times he want and he get vote points on ever click. So, I need it to be 12hour timed. And i don't know how i should do that. I have been looking around on google for some decent vote systems and i have been looking on jquery timed functions. but i cannot figure out something good. Any ideas maybe?

Here is my function:


And here is the html code
 
Last edited:

Vitrex

Moderator
well you can load php file with javascript.
so you load php file and reload it every x seconds

Code:
$(document).ready(function(){
setInterval(function(){
$("#divtoload").load('yourphpfile.php')
}, 1000); // 1 second
});

In your php file make something like that

Code:
if(button_clicked) {    
    $vote_last_time (SELECT last_time WHERE user_id = Session_id);
    if($vote_last_time >= time() - 60 * 60 * 12) {
    mysqli_query(set time when voted last time);
    mysqli_query(giving vp here);
    } else {
        echo "You can't vote now";
    }
}

I think it would look something like that that i simple and not optimized but still example what way i would go and of course make sure to check previous url where user came to make sure that he entered captcha.
 
Last edited:

Tok124

Respected Member
well you can load php file with javascript.
so you load php file and reload it every x seconds

Code:
$(document).ready(function(){
setInterval(function(){
$("#divtoload").load('yourphpfile.php')
}, 1000); // 1 second
});

In your php file make something like that

Code:
if(button_clicked) {    
    $vote_last_time (SELECT last_time WHERE user_id = Session_id);
    if($vote_last_time >= time() - 60 * 60 * 12) {
    mysqli_query(set time when voted last time);
    mysqli_query(giving vp here);
    } else {
        echo "You can't vote now";
    }
}

I think it would look something like that that i simple and not optimized but still example what way i would go and of course make sure to check previous url where user came to make sure that he entered captcha.
Thanks alot ! I will try this soon and see if it works or if i need more help :)

One question, The vote time in database should that be unix time or? Or should i just make the column type to timestamp and use default value "Current Timestamp" or?

I cannot get it to work

I think i managed to solve it myself. Probably not the best method but it seems to work
 
Status
Not open for further replies.
Top