<?php
session_start();
if(!session_is_registered(myusername)){
header("location:index.html");
}
require_once('db.inc.php');
// function for generating errors
function errors($error){ #2
if (!empty($error))
{ #3
$i = 0;
while ($i < count($error)){ #4
echo "<p><span>".$error[$i]."</span></p>\n";
$i ++;} #2
} #3 // close if empty errors
} #4 // close function
$username = $_SESSION['myusername'];
#COMMENT -> You need to put this ^ in, otherwise the $username in the mysql query below is blank.
// You had SELECT ALL `members`... instead of SELECT * FROM `members`...
$sql = "SELECT * FROM `members` WHERE `username` = '$username' LIMIT 1";
$res = mysql_query($sql, $dbc);
$user = mysql_fetch_array($res);
require_once('st.inc.php');
require_once('Army.inc.php');
require_once('stats.inc.php');
srand ((double) microtime( )*1000000);
$find = rand(1,3);
echo "You found " . $find . " logs<br>";
$Wood = $Resources['Wood'];
$addWood = $find;
$newWood = $Wood + $find;
if (!$error) {
mysql_query("UPDATE `Resources` SET `Wood` = '$newWood' WHERE `userid` = '$user[id]' LIMIT 1")
or die(mysql_error());
}
{
errors($error);
}
?>
<html>
Wood: <?php echo $Resources['Wood']; ?>
</html>
<SCRIPT>
function refreshPeriodic() {
// Reload the page every 30 seconds
location.reload();
timerID = setTimeout("refreshPeriodic()", 31000);
}
timerID = setTimeout("refreshPeriodic()", 31000);
</SCRIPT>
<html>
<head>
<script language="JavaScript">
var i=30;
function countDown()
{
if(i > 0)
{
document.forms[0].elements[0].value=i;
i = i-1;
var c = window.setTimeout("countDown()", 1000);
}
}
</script>
</head>
<body onLoad="countDown()">
<form>
<input type="text" name="counter" size="3">
</form>
</body>
</html> Is what I have, I am trying to get it so when the timer reaches 0, you get your wood. It works, but I am having the problem, because if u refresh screen, u automatically get the wood. Anybody know how I can fix this? Tyvm for the help.
.
session_start();
if(!session_is_registered(myusername)){
header("location:index.html");
}
require_once('db.inc.php');
// function for generating errors
function errors($error){ #2
if (!empty($error))
{ #3
$i = 0;
while ($i < count($error)){ #4
echo "<p><span>".$error[$i]."</span></p>\n";
$i ++;} #2
} #3 // close if empty errors
} #4 // close function
$username = $_SESSION['myusername'];
#COMMENT -> You need to put this ^ in, otherwise the $username in the mysql query below is blank.
// You had SELECT ALL `members`... instead of SELECT * FROM `members`...
$sql = "SELECT * FROM `members` WHERE `username` = '$username' LIMIT 1";
$res = mysql_query($sql, $dbc);
$user = mysql_fetch_array($res);
require_once('st.inc.php');
require_once('Army.inc.php');
require_once('stats.inc.php');
srand ((double) microtime( )*1000000);
$find = rand(1,3);
echo "You found " . $find . " logs<br>";
$Wood = $Resources['Wood'];
$addWood = $find;
$newWood = $Wood + $find;
if (!$error) {
mysql_query("UPDATE `Resources` SET `Wood` = '$newWood' WHERE `userid` = '$user[id]' LIMIT 1")
or die(mysql_error());
}
{
errors($error);
}
?>
<html>
Wood: <?php echo $Resources['Wood']; ?>
</html>
<SCRIPT>
function refreshPeriodic() {
// Reload the page every 30 seconds
location.reload();
timerID = setTimeout("refreshPeriodic()", 31000);
}
timerID = setTimeout("refreshPeriodic()", 31000);
</SCRIPT>
<html>
<head>
<script language="JavaScript">
var i=30;
function countDown()
{
if(i > 0)
{
document.forms[0].elements[0].value=i;
i = i-1;
var c = window.setTimeout("countDown()", 1000);
}
}
</script>
</head>
<body onLoad="countDown()">
<form>
<input type="text" name="counter" size="3">
</form>
</body>
</html> Is what I have, I am trying to get it so when the timer reaches 0, you get your wood. It works, but I am having the problem, because if u refresh screen, u automatically get the wood. Anybody know how I can fix this? Tyvm for the help.