Bypassing

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Bypassing

Post by Epiales »

How can I make the "Take Bus" Button Disappear when they successfully have clicked the button? I"ve tried various places with $bypass but have been unsuccessful.

Thanks!

Code: Select all

<?php /////////////////////////////////////////PURCHASING A BUS/////////////////////////////////////////////////

$sql = "UPDATE bususerbdlg SET times1='$currenttime'";
$query = mysqli_query($db_conx, $sql);

?>


<div id="bus">
<table>
<form method='post' action='cabs.php'>
<td class="tooltip"><input type='submit' value='Take Bus'><span>To Travel In A Bus From City To City:<br>Gold: 1K<br>Food: 300<br>Travel Time: 45 Minutes<br>Build Time: 5 Minutes</span></td>
<input type='hidden' name='bus' value='1'></form>
</table>
<?php
if(isset($_POST['bus'])) {

$sql = "SELECT * from bususerbdlg";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);  
      
if ($busplayer = $_SESSION['userid']) {

echo "You already have one"; ?>
<meta http-equiv="refresh" content="1;url=cabs.php">
<?php

} 

if ($stats_gold < 1000) {

?><div id="error"><?php 
echo "<span id='errormess'><big><left><font color='red'>You do not have enough Gold</center></span></big></font>"; ?>
</div>
<meta http-equiv="refresh" content="3;url=cabs.php">

<?php exit;

}

if ($stats_food < 300) {

?><div id="error"><?php 
echo "<span id='errormess'><big><left><font color='red'>You do not have enough Food</center></span></big></font>"; ?>
</div>
<meta http-equiv="refresh" content="3;url=cabs.php">

<?php exit;

}

if ($stats_gold >= 1000 || $stats_food >= 300){

        $gold1 = ($stats_gold - 1000);
        $food1 = ($stats_food - 300);

$update_gold = "UPDATE stats SET gold='$gold1',food='$food1' WHERE $id = '$_SESSION[userid]'";
        $query = mysqli_query($db_conx, $update_gold);

$time = time();
$finish = time() + strtotime($row['times']) + (15 * 1);
$randid = rand(999,9999999);
$bdlgid = 1;

        $sql = "UPDATE bususerbdlg SET times1='$currenttime'";
        $query = mysqli_query($db_conx, $sql);

        $sql = "INSERT INTO bususerbdlg (bdlgid, playerid, times1, finish, randid) VALUES ('$bdlgid','$_SESSION[userid]','$time', '$finish', '$randid')";
        $query = mysqli_query($db_conx, $sql);
        
 }}

?>
<?php

$sql = "SELECT * from bususerbdlg";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);        
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {

if ($row['times1'] >= $row['finish']) {

?> <?php
$bus="<img src='images/bus.png'>";
echo " $bus";

}else{

?>  <?php
echo buildtimes($row['finish'] - $row['times1']);

}      
}
/////////////////////////////////////////END OF PURCHASING A BUS/////////////////////////////////////////////////
?>
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: Bypassing

Post by Winawer »

You're displaying the button before you're checking for the "click" (submit). Switch them around and do some checking for success/failure.
Post Reply

Return to “Beginner Help and Support”