I made a small script wich exchanges points in my website:
<?php
session_start();
include_once"config.php";
$username = $_SESSION['username'];
if(isset($_POST['exchange'])){
$spoints = $_POST['spoints'];
switch ($spoints)
{
case 200:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output = "You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+1 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-200 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 1 more referral.";
}
break;
case 400:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output = "You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+2 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-400 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 2 more referrals.";
}
break;
case 600:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+3 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-600 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 3 more referrals.";
}
break;
case 800:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+4 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-800 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 4 more referrals.";
}
break;
case 1000:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+5 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-1000 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 5 more referrals.";
}
break;
case 1200:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+6 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-1200 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 6 more referrals.";
}
break;
case 1400:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+7 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-1400 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 7 more referrals.";
}
break;
case 1600:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+8 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-1600 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 8 more referrals.";
}
break;
case 1800:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+9 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-1800 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 9 more referrals.";
}
break;
case 2000:
$check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($check_if_have_points);
if($row['points']< 200){
$error_output="You do not have enough points"; }
else {
$updateuserofferstatus = mysql_query("UPDATE `members` SET `offer_status` = offer_status+10 WHERE `username`= '$username'") or die(mysql_error());
$updateuserpoints = mysql_query("UPDATE members SET points=points-2000 WHERE username='$username'");
$error_output = "Congratulations ".$username.". You now have 10 more referrals.";
}
break;
}
}
?>
<div style="width:60%;vertical-align:top;text-align:left;overflow:visible;" id="exchange">
<form action="" method="post">
<fieldset style="border:none;">
<p>
<label for="username" style="font-weight:normal;width:11%;float:left;display:block;">Points:</label>
<input type="text" name="spoints" class="item" value="" />
<span class="style27">(how many points to exchange)</span></p>
<p><input type="submit" name="exchange" value="Exchange" id="exchange" style="float:left;border:1px solid #999;background:#E4E4E4;margin-top:5px;" /></p>
</fieldset>
</form>
<font color="red"><?php echo $error_output?></font></div>
It works great ... but the problem is after I enter the points and they are exchanged, if i refresh the page they get exchanged again. How can I resolv this. I tried addind some meta refresh but it doesn't resolve the problem
Executing an exe
Hi. I have some bizarre problem with exec (other any other method) to launch exe's. I am making a game server booking system and the part that is not working is the one with the launching the server
update the selected existing records of database
Hi frndz,I am new to php and get stuck.... Edit.php > Update.php > Updateaction.phpi have 1 edit page displaying results existing in database with chkbox in front of every record and
Help With editting and deleting form
Hallo !!So look at this image :http://img194.imageshack.us/img194/8272/snapshot5f.png This table prints the titles of entries from a table in a database.. The code that i use for this table is this
EU VAT Package 2010
Does any one know whether SAP will be developing new reporting functionality due the new VAT rules the European Commission want to implement from 2010?
division gives infinity anser
int main(){ int z=0; int i=1/z; cout<<i;}It doesn't throw any error in Visual Studio 2008. .......What setting one has to change so that it will show runtime error in VS 2008.....
first id from db not showing
I have a php script which displays the content of a mysql table as a html table with sorting, delete/update button, etc. the problem is I can't make it show the first value inserted in the db, it only
Best way to read this text file.
Hi.I am planning to make a small application in C# to convert the players from Football manager 2010 game into Fifa 10 game.I have this text file exported from
get the country of visitor and display content based on that
Hello all,I have seen that Google analytics can tell you where a visitor is coming from and I want to do something similar. But I would like to add the functionality of redirecting a user based on his
retrieving images from mysql database using php
So I've been trying to figure out how to store images in a mysql database, and as far as i can tell the images are stored but getting them out seems to be the problem. when i try to go to the page on
php mysql query from input textbox
Hi,I have a text box, in that i have given the mysql query. I can able to get the query in variable. But after submit button i want to get data to be printed on a same page. But how can i print the