papiskMUSE Posted November 7, 2009 Share Posted November 7, 2009 Hello I would like to have script for a game where users would normally register for a game and there would be a vote button and when someone pushes it it asks for their account details. Login: Password: Security code: If all filled in matches with the data in the database they would be given an framed vote website where they would need to fill in the words and submit. After they submited the site would automatically refresh and a reward or count would be given near their username in the database table should look something like this Username Password Votes VIP Money Arnoldas (coded) 1 0 15151 And each day i would run through the database and restore their votes to 0 but adding them a reward like money. If you dont quiet get it please ask, ill try to explain you what i mean Please help me Thank You Arnoldas Link to comment https://forums.phpfreaks.com/topic/180667-php-voting-system-mysql-add-data/ Share on other sites More sharing options...
papiskMUSE Posted November 7, 2009 Author Share Posted November 7, 2009 Ok I found what I was searching for but don't know how to configure on my database Can someone help me? what extra tables i need to create? <?php $unixts = date("U"); $unix_12hours = date("U") - (12*60*60); $dbhost = "127.0.0.1"; //database host goes here $dbuser = "your_user"; //database user goes here $dbpass = "your_password"; //database password goes here $dbname = "world"; //database name goes here mysql_connect($dbhost, $dbuser, dbpass); mysql_select_db($dbname); $user = mysql_real_escape_string($_POST['user']); $success = true; $problemMessage = "Cannot connect to mysql server"; if (isset($_POST['Submit'])) { if(!$user); { $problemMessage .= "Please enter your account name <br />"; $success = false; } if ($success) { $sql = "SELECT COUNT(*) as `total_users` FROM `accounts` WHERE `lastvote` <= $unix_12hours AND `username` = $user LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); if ($row['total_users'] == 1){ mysql_query("INSERT INTO mailbox_insert_queue VALUES('$user','$user','Thanks for voting','Thanks for voting for our server please take this token as a thank you from our staff Thanks from the Sinister WoW team','61','0','1234500','1')"); //1234500 is the id for our token mysql_query("UPDATE `users` SET `last_voted` = $unixts WHERE `username` = '$user' LIMIT 1;"); header('Location: http://www.site.com'); /* <----------- MODIFY THIS URL!!!!!!!!!!!!!!!! */ exit(); } else{ $problemMessage = "You have voted in the past 12 hours"; } } } ?> <html> <head> <title>Voting Page</title> </head> <body> <form> Username: <input name="user" type="text"/><br> <input name="Submit" type="submit" value="Vote" /> </form> </body> </html> What new tables i need to create? Can someone modify for me. So that the script would not check the account because this would only appear if account is logged in in the website so no need for extra checks. All i want is when user logs in into his web account button will appear in his CP to vote and when he votes it will add +1 to some table so each day i can run through the db and restore their points to 0 and add to them a reward. Link to comment https://forums.phpfreaks.com/topic/180667-php-voting-system-mysql-add-data/#findComment-953294 Share on other sites More sharing options...
papiskMUSE Posted November 7, 2009 Author Share Posted November 7, 2009 Ok I have managed to create register and login page. Now I need to create users vote button where all the magic happens. How can I edit code above to add +1 to its user table? Link to comment https://forums.phpfreaks.com/topic/180667-php-voting-system-mysql-add-data/#findComment-953382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.