On Page Load Shouldn't [Resolved]
Posted: Sat Oct 19, 2013 3:04 pm
Okay, the problem I'm running into now is that upon going to the page, if you don't have enough gold to get the bus, or so, then it tells you the error message that you don't have enough gold. That is supposed to show WHEN they CLICK on the bus, or the taxi, but not WHEN the page loads... Why? And when I do have enough gold, it automatically starts the countdown timer for the bus?
Code:
Code:
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>Build Time: 45 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 ($stats_gold < 1000) {
echo "<span id='errormess'><big><left><font color='red'>You do not have enough Gold</center></span></big></font>";
}
elseif ($stats_food < 300) {
echo "<span id='errormess'><big><left><font color='red'>You do not have enough Food</center></span></big></font>";
}
elseif ($owned = 1) {
echo "<span id='errormess'><big><left><font color='red'>You Already Own This</center></span></big></font>";
}else 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";
$sql = "UPDATE bususerbdlg SET owned='1' WHERE playerid = '$_SESSION[userid]'";
$query = mysqli_query($db_conx, $sql);
}else{
?> <?php
echo buildtimes($row['finish'] - $row['times1']);
}
}
/////////////////////////////////////////END OF PURCHASING A BUS/////////////////////////////////////////////////
?>