i got this script here which dont work. i getting user input, but it dont seem to be getting in. its $att_turns, i had type "int" rofl, which i suppose wont help. anyhoo, i had a debug in and it shows that it aint getting in. and the code below it isnt getting excecuted. why is it not getting excecuted?? can someone take a look and see if they can spot the problem please?
<?
(!defined('')) ? die : '';
session_start();
(!isset($_SESSION['user_id'])) ? redirect('index.php?mode=login') : '';
$set = (isset($_GET['set'])) ? $_GET['set'] : '';
$target_userid = (isset($_GET['uid'])) ? intval($_GET['uid']) : redirect('index.php?mode=members');
$user_id=$_SESSION['user_id'];
if (!isset($HTTP_POST_VARS['attack']))
{
$uresult = mysql_query("SELECT * FROM users
WHERE user_id=$user_id");
$user=mysql_fetch_assoc($uresult);
if ($user)
{
echo 'user succeeded';
}else{
echo 'user failed';
}
$target = mysql_query("SELECT * FROM users
WHERE user_id = '".$target_userid."'");
$target = mysql_fetch_assoc($target);
if ($target)
{
echo'target succeeded';
}else{
echo 'target failed';
}
if ($target_userid == $_SESSION['user_id'])
{
echo 'You cannot attack yourself';
timed_redirect('index.php?mode=attack&set=no', 2);
die;
}
echo 'Maximum ammount: <b>15</b>
<form action="index.php?mode=attack&uid='.$target_userid.'" method="POST">
Turns: <input type="int" name="att_turns" size="10" /><br />
<input type="submit" value="submit" name="submit"/>
<input type="hidden" name="attack" value="true" />
</form>';
$attack_turns = (isset($_POSTS['att_turns'])) ? intval($_POST['att_turns']) : '';
echo 'turns entered- '.$attack_turns;
echo 'user turns- '.$user['user_turns'];
echo "!!!use attack ".$user['user_attack_rating']."<br>";
echo "!!! target def ".$target['user_defence_rating']."<br>";
//the below code does not seem to be getting carried out. the attack turns arent getting deducted
//the users gold is getting set to 0 too
//is user['user_turns'] getting referenced properly, aswell as the other vars??
//could you please check each variable and check its getting referenced properly?
} else if (isset($HTTP_POST_VARS['attack']))
{
if ($user['user_turns'] >= $attack_turns)
{
if ($attack_turns > 0 && $attack_turns <= 15)
{
if ($user['user_attack_rating'] > $target['user_defence_rating'])
{
$spoils = round(((4.3 * ($target['user_gold']/100)) * $user_turns));
echo'!!! '.$user['user_turns'].'<br>';
echo'!!'.$attack_turns.'<br>';
echo '!!'.$user_turn.'<br>';
$user_result = mysql_query("UPDATE users
SET user_gold = '".$user_gold+$spoils."',user_turns='".$user_turns-$attack_turns."'
WHERE user_id = '".$_SESSION['user_id']."'");
$target_result = mysql_query("UPDATE users
SET user_gold = '".$target_gold-$spoils."'
WHERE user_id = '".$target_userid."'");
$victory = true;
$outcome = 'Victory';
echo "Your troops demolish $target' s army, victory is yours" ;
echo '<br>You have gained:<br><b>'.$spoils.' Gold</b><br><b></b>';
} else {
$victory = false;
$outcome = 'Defeat';
echo '!! '.$target.' s army beats back your army in a humiliating defeat!' ;
$user_resultd = mysql_query("UPDATE users
SET user_turns='".$user_turn-$attack_turns."'
WHERE user_id = '".$_SESSION['user_id']."'");
}
$result = mysql_query("INSERT INTO `attack_log` VALUES ('".$_SESSION['username']."', '".$target['username']."', '".$user['user_attack_rating']."', '".$target['user_def_rating']."', '".$outcome."', '".$spoils."')");
if ($result)
{
echo 'Attack Log Updated!';
if($user_result)
{
echo'user Stats updated';
timed_redirect('index.php?mode=main', 10);
} else {
echo'user stat update failed';
timed_redirect('index.php?mode=main', 10);
}
if($user_resultd)
{
echo'user Stats updated';
timed_redirect('index.php?mode=main', 10);
} else {
echo'user stat update failed';
timed_redirect('index.php?mode=main', 10);
}
if($target_result)
{
echo'target Stats updated';
timed_redirect('index.php?mode=main', 10);
} else {
echo'target stat update failed';
timed_redirect('index.php?mode=main', 10);
}
}
}
}else{
echo 'You do not have enough turns';
timed_redirect('index.php?mode=attack', 3);
}
}
?>