problems with script


Posted on 16th Feb 2014 07:03 pm by admin

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

No comments posted yet

Your Answer:

Login to answer
307 Like 21 Dislike
Previous forums Next forums
Other forums

How would I do "Users not logged in since *** delete them"
I know how I would set this up, and delete the user roughly.
I'll create a table called "Use

form help
this doesn't work. i want the form action to go the location.href of the submit button chosen.. how

ORA-01655: unable to extend cluster SYS.C_FILE#_BLOCK# by 128
Hi all,

Oracle 10g. Linux.

I'm facing the below error while trying to import a dumpfil

pls clear my confusion
Hi friends,

Pls solve my query .

what is the exact use of Scope Resolution Operator( i

INSERT for date range
Hi all

I have the following table

Code: [Select] `date` date
`day` int(2)
`

how to export excel file in same server
My first post - php newbie, so appreciate your support.

I'm currently using headers to save w

Using real time in php
I'm very average at PHP and im looking to introduce time to something on my site.
Its a sports si

Mysterious Timeouts
I've deployed a few simple AJAX-enabled web page to a local server that is accessed through the Inte

Wrong Info sent Using $get in form
Hi i have this code that i tried to make to send some info from one page to aother with lots of ppls

php not working written for consumption of slots
1. Here is the function where i will be allowed to consume the slot booked by me.

2. Here i c

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash