Refreshing select page content.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    Refreshing select page content.

    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_co nfirmed == TRUE) { echo ('<b>Transactio n completed!</b>'); }
    ?>

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

    <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#00000 0">
    <tr>
    <td class="TL_2">&n bsp;</td>
    <td class="T_2">&nb sp;</td>
    <td class="TR_2">&n bsp;</td>
    </tr>
    <tr>
    <td class="L_2">&nb sp;</td>
    <td>
    <?php include('../age_0/army_files/unit_table.php' ); ?>
    </td>
    <td class="R_2">&nb sp;</td>
    </tr>
    <tr>
    <td class="BL_2">&n bsp;</td>
    <td class="B_2">&nb sp;</td>
    <td class="BR_2">&n bsp;</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\">her e</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("UP DATE supwar_stats SET stats_s_f='$new _stats_s_f' WHERE stats_name='$us er_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_co nfirmed = TRUE;

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


    }
    }
    }

    ?>[/PHP]
    Last edited by TheServant; Feb 15 '08, 04:56 PM. Reason: Requested Code
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You have not shown what PHP code constructs this page. Show any code within the appropriate code tags!

    Ronald

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      Originally posted by ronverdonk
      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.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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

        Comment

        • TheServant
          Recognized Expert Top Contributor
          • Feb 2008
          • 1168

          #5
          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="#00000 0">
          <tr>
          <td width="75" class="title">U nits:</td>
          <td width="100" class="title">D isband:</td>
          <td width="200" class="title">R ecruit Cost:</td>
          <td width="100" class="title">R ecruit:</td>
          <td width="100" class="title">T rained:</td>
          </tr>
          <tr>
          <td class="text"><? php echo($user_race _data['races_s_f_n']); ?></td>
          <td class="text"><i nput name="disband_s _f" type="text" value="0" size="4" maxlength="6" /></td>
          <td class="text"><? php echo('Gold: '.$user_race_da ta['races_s_f_cg'].', Food: '.$user_race_da ta['races_s_f_cf']); ?></td>
          <td class="text"><i nput 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"><i nput name="disband_s _r" type="text" value="0" size="4" maxlength="6" /></td>
          <td class="text"><? php echo('Gold: '.$user_race_da ta['races_s_r_cg'].', Food: '.$user_race_da ta['races_s_r_cf']); ?></td>
          <td class="text"><i nput 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"><i nput name="disband_s _m" type="text" value="0" size="4" maxlength="6" /></td>
          <td class="text"><? php echo('Gold: '.$user_race_da ta['races_s_m_cg'].', Food: '.$user_race_da ta['races_s_m_cf']); ?></td>
          <td class="text"><i nput 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="#00000 0">
          <tr>
          <td class="text" align="right">
          <input type="submit" value="Train" />
          </td>
          </tr>
          </table>
          </form>[/HTML]

          Comment

          • TheServant
            Recognized Expert Top Contributor
            • Feb 2008
            • 1168

            #6
            Do I have to use frames?

            Comment

            Working...