Jump to content

php script is loading itself....


2DaysAway

Recommended Posts

Here's the scenario:

Player clicks link when turns are available

<a href="bonuscredits.php?rid=<?=$rid?>"><font size="-2">(add bonus turns)</font</a>

 

Now, it should just take them to the bonuscredits page and then the player has to manually click the submit button to get his/her turns. BUT, what is happening is the player clicks the link for the bonuscredits and the next thing the player knows, he has his turns and never even saw the bonuscredits page. I'll post the code for the bonuscredits page, could someone please take a look and let me know why it's automatically running the script when I thought it should show the form and allow the player to choose....

 

<?php 
include("game_html.php");
$game="yes";
mysql_query("UPDATE `{$tab[pimp]}` SET `currently`='adding bonus turns', `online`='$time' WHERE `id`='$id' AND `rid`='$rid'");
$user = mysql_fetch_array(mysql_query("SELECT credit,username FROM `{$tab[user]}` WHERE `id`='$id';"));
$un=$user["username"];
$pimp = mysql_fetch_array(mysql_query("SELECT pimp,transfer,bonusturntime,bonusturns,bonusturnsuses FROM `{$tab[pimp]}` WHERE `id`='$id' AND `rid`='$rid';"));
$user2 = mysql_fetch_array(mysql_query("SELECT id FROM `{$tab[pimp]}` WHERE `pimp`='$pmp' AND `rid`='$rid';"));
$adminid="5";
$bonustransfer=$pimp[bonusturns];
$timeleft=$time-$pimp[bonusturntime]; 

//add bonus turns
if ($bonustransfer){
  if($time < $pimp[bonusturntime]){ $msg='You have to wait before receiving bonus turns'; }
  elseif($time < $site[starts]){ $msg="You must wait until this game starts!"; }
  elseif($bonustransfer > $user[credit]){ $msg="You dont have that many credits!"; }
  else{
   $pimp = mysql_fetch_array(mysql_query("SELECT bonusturnsuses,crewjoindate,crewbonusturns,bonusturns,loyality,crew FROM `{$tab[pimp]}` WHERE `id`='$id' AND `rid`='$rid';"))or die("Error : " . mysql_error());
   $user = mysql_fetch_array(mysql_query("SELECT credit FROM `{$tab[user]}` WHERE `id`='$id';"))or die("Error : " . mysql_error());
   $bonustime=$time+172800;//bonus turns every 48 hours
   $crewquery = "SELECT members FROM `{$tab[crew]}` WHERE `id`='$id' AND `rid`='$rid'";
   $ct=$crewquery["members"];
   $cjd=$pimp["crewjoindate"];
   $cbt=$pimp["crewbonusturns"];
   $btu=$pimp["bonusturnsuses"];
   $pcw=$pimp["crew"];
   $btu=$pimp["bonusturnsuses"];
   if($pcw<=0){$bt=0;}
   else{$bt=10;}
   $enddate=$time;
   $diff=$enddate-$cjd;
   // immediately convert to days
   $temp=$diff/86400; // 60 sec/min*60 min/hr*24 hr/day=86400 sec/day
   // days
   $days=floor($temp);  $temp=24*($temp-$days);
   $ply=$pimp["loyality"];
   if($pcw<=0){$xbt=0;}
   else{$xbt=$days*$bt;}
   if($pcw<=0){$lxbt=0;}
   else{$lxbt=$bt*$ply;}
   $bonusturns=$pimp["bonusturns"]+$cbt+$lxbt;
   $adminmessage="Auto-Response: you received ". $bonusturns ." bonus turns.";
mysql_query("INSERT INTO `{$tab[mail]}` (rid,src,dest,msg,time,inbox) VALUES ('$rid','$adminid','$id','$adminmessage','$time',2);")or die("Error : " . mysql_error("tabmail error"));
mysql_query("UPDATE `{$tab[pimp]}` SET `messages`=messages+1 WHERE `id`='$id' AND `rid`='$rid'")or die("Error : did not update message bin" . mysql_error());
mysql_query("UPDATE `{$tab[pimp]}` SET `bonusturnsuses`=$btu+1 WHERE `id`='$id' AND `rid`='$rid'")or die("Error : did not update bonus turn count" . mysql_error());
mysql_query("UPDATE `{$tab[pimp]}` SET `loyalityturns`=$lxbt WHERE `id`='$id' AND `rid`='$rid'")or die("Error : did not update loyality turn count" . mysql_error());
mysql_query("UPDATE `{$tab[pimp]}` SET `turn`=turn+$bonustransfer+$cbt+$lxbt, `bonusturntime`=$bonustime WHERE `id`='$id' AND `rid`='$rid'")or die("Error : did not give turns" . mysql_error());
mysql_query("UPDATE `{$tab[pimp]}` SET `crewbonusturns`=crewbonusturns+$xbt WHERE `id`='$id' AND `rid`='$rid'")or die("Error : did not give crew bonus turns" . mysql_error());
mysql_query("UPDATE `{$tab[user]}` SET `credit`=credit-$bonustransfer WHERE `id`='$id'")or die("Error :did not deduct credits from account " . mysql_error());
mysql_query("INSERT INTO `{$tab[credits]}` (id,username,action,time,ip) VALUES ('','$un','$adminmessage','$time','$REMOTE_ADDR');")or die ("Did not INSERT info into credit table   " .mysql_error ());
header("Location: buyturns.php?rid=$rid");
      }
}
$user = mysql_fetch_array(mysql_query("SELECT credit FROM `{$tab[user]}` WHERE `id`='$id';"));
?>

<div class="inside_box_header">Your account currently has
  <?=commas($user["credit"])?>
  credits.
  <div class="inside_box">
    <form method="post" action="bonuscredits.php?action=bonustransfer">
      <b>transfer your credits for more turns</b>
      <input type="submit" class="button" value="transfer" name="bonustransfer">
      <table align="center" cellspacing="1" cellpadding="4">
        <?if($msg){?>
        <div class="boxdef-hd">
          <div class="boxdef">
            <center>
              <b><font color="#ffffff">
              <?=$msg?>
              </font></b>
            </center>
          </div>
        </div>
        <?}?>
      </table>
    </form>
  </div>
</div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.