By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

Refreshing select page content.

TheServant
Expert 100+
P: 1,168
Hey there again,
I have made a form which allows users to train soldiers depending on whether or not they have the resources. The content concerned is set out like this:

-- Header --
-- Info Bar (how much gold etc available) --
-- Form --
-- Footer --

Here is a screen shot:



Now when I submit the form, it updates everything except for the Info Bar. Obviously when you refresh the page, the Info Bar is correct, but submitting the form doesn't effect the Info Bar at all. I do not want to have the Info Bar in the form!

Is there anyway which I could submit the form (without including the Info Bar in the form) and have that line of code updated?

Thanks for your time!


[PHP]<?php include("../main/header.php"); ?>
<?php include('../age_0/forms/army_form.php'); ?>

<?php
if ($_SESSION['user_name'] == NULL)
{
echo("<p class=\"error\">You have not filled in your username/password. </p><br />");
} else {
?>

<?php
if ($tansaction_confirmed == TRUE) { echo ('<b>Transaction completed!</b>'); }
?>

<?php include('../age_0/army_files/user_race_data.php'); ?>

<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000">
<tr>
<td class="TL_2">&nbsp;</td>
<td class="T_2">&nbsp;</td>
<td class="TR_2">&nbsp;</td>
</tr>
<tr>
<td class="L_2">&nbsp;</td>
<td>
<?php include('../age_0/army_files/unit_table.php'); ?>
</td>
<td class="R_2">&nbsp;</td>
</tr>
<tr>
<td class="BL_2">&nbsp;</td>
<td class="B_2">&nbsp;</td>
<td class="BR_2">&nbsp;</td>
</tr>
</table>[/PHP]

[PHP]<?php
if ( ($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['disband_s_f']) && isset($_POST['disband_s_r']) && isset($_POST['disband_s_m']) && isset($_POST['recruit_s_f']) && isset($_POST['recruit_s_r']) && isset($_POST['recruit_s_m']) )
{

if ($_SESSION['user_name'] == NULL)
{
echo("<p class=\"error\">You have not logged in yet. Click <a href=\"../age_0/login.php\">here</a> to login. </p><br />");
} else {


/*-----------------------------------------------------------------------------------------------------------------------
mySQL Connect Code
-----------------------------------------------------------------------------------------------------------------------*/
...
/*-----------------------------------------------------------------------------------------------------------------------
Data Collection Code
-----------------------------------------------------------------------------------------------------------------------*/
...
/*-----------------------------------------------------------------------------------------------------------------------
Buy Code
-----------------------------------------------------------------------------------------------------------------------*/

$new_stats_s_f = ( $_SESSION['stats_s_f'] + $_POST['recruit_s_f'] );
...

mysql_query("UPDATE supwar_stats SET stats_s_f='$new_stats_s_f' WHERE stats_name='$user_name'") or die('I cannot update Stats Table because: ' . mysql_error());
...

...
$_SESSION['stats_s_f'] = $new_stats_s_f;
...
$_SESSION['stats_food'] = $new_stats_food;

$transaction_confirmed = TRUE;

//-----------------------------------------------------------------------------------------------------------------------


}
}
}

?>[/PHP]
Feb 15 '08 #1
Share this Question
Share on Google+
5 Replies


ronverdonk
Expert 2.5K+
P: 4,258
You have not shown what PHP code constructs this page. Show any code within the appropriate code tags!

Ronald
Feb 15 '08 #2

TheServant
Expert 100+
P: 1,168
You have not shown what PHP code constructs this page. Show any code within the appropriate code tags!

Ronald
Updated original post to include that.
Feb 15 '08 #3

ronverdonk
Expert 2.5K+
P: 4,258
I cannot see a form, so that makes it a bit difficult. You don't have to have the bar in the form itself. Anyway, you can only do this by re-showing the bar-information after submit. So you either re-draw the bar after POST or redraw part of the bar (counter part) in 'real time' (using Ajax) after an event.

Ronald
Feb 15 '08 #4

TheServant
Expert 100+
P: 1,168
Sorry, I keep forgetting to put in the code where I use include!

[HTML]<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000">
<tr>
<td width="75" class="title">Units:</td>
<td width="100" class="title">Disband:</td>
<td width="200" class="title">Recruit Cost:</td>
<td width="100" class="title">Recruit:</td>
<td width="100" class="title">Trained:</td>
</tr>
<tr>
<td class="text"><?php echo($user_race_data['races_s_f_n']); ?></td>
<td class="text"><input name="disband_s_f" type="text" value="0" size="4" maxlength="6" /></td>
<td class="text"><?php echo('Gold: '.$user_race_data['races_s_f_cg'].', Food: '.$user_race_data['races_s_f_cf']); ?></td>
<td class="text"><input name="recruit_s_f" type="text" value="0" size="4" maxlength="6" /></td>
<td class="text"><?php echo($_SESSION['stats_s_f']); ?></td>
</tr>
<tr>
<td class="text"><?php echo($user_race_data['races_s_r_n']); ?></td>
<td class="text"><input name="disband_s_r" type="text" value="0" size="4" maxlength="6" /></td>
<td class="text"><?php echo('Gold: '.$user_race_data['races_s_r_cg'].', Food: '.$user_race_data['races_s_r_cf']); ?></td>
<td class="text"><input name="recruit_s_r" type="text" value="0" size="4" maxlength="6" /></td>
<td class="text"><?php echo($_SESSION['stats_s_r']); ?></td>
</tr>
<tr>
<td class="text"><?php echo($user_race_data['races_s_m_n']); ?></td>
<td class="text"><input name="disband_s_m" type="text" value="0" size="4" maxlength="6" /></td>
<td class="text"><?php echo('Gold: '.$user_race_data['races_s_m_cg'].', Food: '.$user_race_data['races_s_m_cf']); ?></td>
<td class="text"><input name="recruit_s_m" type="text" value="0" size="4" maxlength="6" /></td>
<td class="text"><?php echo($_SESSION['stats_s_m']); ?></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000">
<tr>
<td class="text" align="right">
<input type="submit" value="Train" />
</td>
</tr>
</table>
</form>[/HTML]
Feb 16 '08 #5

TheServant
Expert 100+
P: 1,168
Do I have to use frames?
Feb 16 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.