Hello
I need a php reward script (MYSQL & PHP)
i found this on ******* but no works because no have config on topic please help me
I need a php reward script (MYSQL & PHP)
i found this on ******* but no works because no have config on topic please help me
<?php
//Includes the database information
include("config.php");
//makes the .php?action
switch($_GET['action']) {
//the defualt page to display
default:
//Show the page for the user to cliam a reward
echo "<form method=\"POST\" action=\"?action=claim\">
<input type=\"text\" name=\"n1\" size=\"5\" maxlength=\"4\">-<input type=\"text\" name=\"n2\" size=\"5\" maxlength=\"4\">-<input type=\"text\" name=\"n3\" size=\"5\" maxlength=\"4\">
<input type=\"submit\" value=\"Claim\" name=\"claim\"></form>";
break;
case "claim":
//posts the data
$n1 = $_POST[n1];
$n2 = $_POST[n2];
$n3 = $_POST[n3];
//check if the code exists in the database
$getcode=mysql_query("SELECT * FROM rewards where code = '" . $n1 . $n2 . $n3 . "'");
$getcode = mysql_num_rows($getcode);
if ($getcode == 0)
{
//If code does not exists give error
echo ("Invalid Reward code!");
}
else
{
//if code exists get db ifo
$code=mysql_query("SELECT * FROM rewards where code = '" . $n1 . $n2 . $n3 . "'");
$code2 = mysql_fetch_array($code);
//change the varible
$amount = $code2[reward];
//adds the points
$add = mysql_query("SELECT * FROM users WHERE username = '".$logged['username']."'") or die(mysql_error());
$add = mysql_fetch_array($add) or die(mysql_error());
$points = $add['points'] + $amount;
$update = mysql_query("UPDATE users SET points = '".$points."' WHERE username = '".$logged['username']."'") or die(mysql_error());
//UPDATE THE LINE ABOVE WITH YOUR OWN SQL DATA
//deletes the old code so it can not be used again
$delete = mysql_query("DELETE FROM `rewards` WHERE code = '" . $n1 . $n2 . $n3 . "'");
//tells the the got the reward
echo "You claimed your reward of $amount gold";
}
break;
case "admin":
//checks if there a admin
if($logged[username] && $logged[level] ==5)
{
//form to add points to a code
echo "<form method=\"POST\" action=\"?action=addcode\">
Reward Points: <input type=\"text\" name=\"reward\" size=\"10\" maxlength=\"5\">
<br><input type=\"submit\" value=\"Add Reward\" name=\"add\"></form>";
}
break;
case "addcode":
//checks if there a admin
if($logged[username] && $logged[level] >=5)
{
//letter what can be used in the code
$alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
//random 4 letter codes
$r1 = substr(str_shuffle($alphanum), 0, 4);
$r2 = substr(str_shuffle($alphanum), 0, 4);
$r3 = substr(str_shuffle($alphanum), 0, 4);
//gets the amount from a post
$reward = $_POST[reward];
//insert the code and reward into the database
$query = mysql_query("INSERT INTO rewards (code, reward) VALUES('$r1$r2$r3','$reward')");
//echos the code out
echo " +===================================+<br>
| Gold Center
|<br>
+===================================+<br>
| Code: $r1 - $r2 - $r3<br> | Reward: $reward<br>
+===================================+";
}
break;
}
?>