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

Run function every 5 mins ??
I have a function PostMessage()

How can I run it every 5 mins ??

Update not working ... please help
Hi,

I am trying to update a row using an edit form by passing id of the row .. but it is not

Using Windows message as a Handle
Hi,

I am writing one of my first multithreaded programs.

In one of the thread,

Operator precedence assistance.
I did a quick Google search and couldn't quite find the answer I wanted in terms I could understand,

COde for a Cc
I'm not receiving $ft as a Cc. Why is that??

$to = "$email";
$headers = "Fr

Quick variable question
hey guys/gals,
im trying to write a php script and it works fine as i have it, but i need to set

Login Functionality Working Different on IE
This is an odd one, I have a site which has an admin section. The admin pages unsurprisingly require

Credit card verification
I have a client who wants to process credit card transactions from his web site rather than the goin

Simple Scraper... Weird Output
Okay, maybe I just need a Blue Monster and some sleep, but....

I'm scraping a ringtone site

A little help needed passing hidden values to next page
I have a page that has hidden values in a form.

example
Code: <input name='signupID

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