Queso
echo 'Web Developer';
- Nov 29, 2016
- 232
- 72
Hi there DevBest, releasing another basic simple script. Basically this script allows a user to get a free item everyday, which can be selected from a table in the database.
First off, add this code to the page.
Next, create a new file called reward.php and paste this into it
P.S, this was made on a Habbo theme, so you may have to change some lines if you use a different skin than Habbo
Lastly, run these queries in your Navicat
Screenshots:
Done.
If you have any questions or need help, PM me, and I can try to help you. Don't really care if you think this poorly coded or anything, I'm not a professional web developer, nor do I really know of ways this can be sql injected, so yeah. This was just something I wanted to have on my hotel.
First off, add this code to the page.
Code:
<center>Here at <strong>{hotelname}</strong> we reward our active users with various items. <br />
Everyday you login, you can click on the box below to receive an item in-game. <br /></center>
</p>
<center><a href="#" onclick="window.open('{url}/reward', 'newwindow', 'width=300, height=180');" target="_blank"><img src="IMAGEHERE"></a></center>
PHP:
<?php
$user = mysql_query("SELECT * FROM `users` WHERE id='".$_SESSION['user']['id']."'");
while ($u = mysql_fetch_array($user)){
if ($u['id'] > 0 || $u['id'] != null){
if(date("Y-m-d") == date("Y-m-d", $u['account_created'])){
echo "<br><div class=\"rounded-green rounded-done\">You need to be a member for at least one day!</div>";
}
else
{
if ($u['online'] == 0){
if(date("Y-m-d") == $u['lastusedgift']){
if ($u['lastmysteryprize'] == null){
echo '<div class="rounded-red rounded-done">You can only receieve one reward per day!</div>';
} else {
echo '<br><div class="rounded-red rounded-done">You can only receive one reward per day!</div>';
echo '<br><div class="rounded-red rounded-done">You last received a '.$u['lastdailygift'].'!</div>';
}
} else {
$rare = mysql_query("SELECT * FROM `gift_settings` ORDER BY RAND() LIMIT 1");
$r = mysql_fetch_assoc($rare);
if ($r){
$urRare = $r['rare_id'];
$urRareName = $r['rare_name'];
$urRareImg = $r['rare_img'];
mysql_query("INSERT INTO `items` (`user_id`, `base_item`, `extra_data`) VALUES ('".$_SESSION['user']['id']."', '".$urRare."', '0')");
mysql_query("UPDATE `users` SET `lastusedgift` = '".date("Y-m-d", time())."' WHERE `id` = '".$_SESSION['user']['id']."'");
mysql_query("UPDATE `users` SET `lastdailygift` = '".$urRareName."' WHERE `id`='".$_SESSION['user']['id']."'");
echo '<br><div class="rounded-green rounded-done">You have just received a '.$urRareName.'!</div>';
}}
} else {
echo "<br><div class=\"rounded-red rounded-done\">Make sure you're logged out of the client first!</div>";
}
}}}
?>
Lastly, run these queries in your Navicat
Code:
ALTER TABLE users ADD lastusedgift varchar(255);
Code:
ALTER TABLE users ADD lastdailygift varchar(255);
Code:
DROP TABLE IF EXISTS `gift_settings`;
CREATE TABLE `gift_settings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`rare_name` varchar(255) DEFAULT NULL,
`rare_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
You must be registered for see links
You must be registered for see links
You must be registered for see links
You must be registered for see links
You must be registered for see links
Done.
If you have any questions or need help, PM me, and I can try to help you. Don't really care if you think this poorly coded or anything, I'm not a professional web developer, nor do I really know of ways this can be sql injected, so yeah. This was just something I wanted to have on my hotel.
Last edited: