Jump to content

[SOLVED] Post a variable to the same page


oceans

Recommended Posts

NOT working,

 

I will give you my situation..

 

<?PHP
if ($_POST["Flag"]==1)
{
bla bla bla
}
else
{
bla bla bla
$Flag=1;
}
?>
<input type="hidden" name="Flag" value="<?PHP echo $Flag; ?>">

 

I want to transfer this Flag value for if else operation that is all

 

Thanks

I did this, to do somthing on the first run of the page, than on the second run do somthing else.

 

I was hasty with my earlier reply, the idea works, but the the process goes to if ($_POST["Flag"]==1)

on the third run not the second. any possible reason.

 

you want my modified code?

<?php
ob_start();
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?PHP
if (isset($_POST['CountryName'])) 
{
$CountryName=$_POST["CountryName"];//current variable
}
else
{
$CountryName="";
}
?>
<form id="form1" name="form1" method="post" action="0701View.php">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="Background05">
    <tr>
      <td><table width="765" border="0" align="center" cellpadding="5" cellspacing="0">
        <tr>
          <td> </td>
        </tr>
        <tr>
          <td> </td>
        </tr>
        <tr>
          <td><hr class="Line1" /></td>
        </tr>
        <tr>
          <td><table width="755" border="0" cellpadding="5" cellspacing="0">
            <tr>
              <td><hr class="Line2" /></td>
            </tr>
            <tr>
              <td> </td>
            </tr>
            <tr>
              <td width="745"><table width="745" border="0" cellpadding="5" cellspacing="0">
                <tr>
                  <td width="170" class="FieldName">Country</td>
                  <td width="555" class="FieldName">
				  <select name="CountryName" size="1" class="FieldValue" onchange='this.form.submit()' id="CountryName">
                        <option value="" selected="selected"></option>
                        <option value="Afghanistan">Afghanistan</option>
                      </select></td>
                </tr>
                <tr>
                  <td class="FieldName">State</td>
                  <td class="FieldValue">
                    <?PHP
				echo $_POST["Local_session_id"];
echo "<input name=\"Local_session_id\" type=\"hidden\" class=\"FieldValue\" id=\"Local_session_id\" value=\"$session_id\">";
if ($CountryName!="")//current variable
{
$_SESSION['07ForView1']=$CountryName;
//header("location: 0702View.php");
}
?>                  </td>
                </tr>
                <tr>
                  <td class="FieldName">City</td>
                  <td class="FieldValue"> </td>
                </tr>
                <tr>
                  <td class="FieldName">Town</td>
                  <td class="FieldValue"> </td>
                </tr>
                <tr>
                  <td class="FieldName">Street</td>
                  <td class="FieldValue"> </td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td><hr class="Line2" /></td>
        </tr>
        
      </table>
      </td>
    </tr>
  </table>
</form>
</body>
</html>code]

value for

"

echo $_POST["Local_session_id"];

" on the second run

 

because on the first run

"

echo "<input name=\"Local_session_id\" type=\"hidden\" class=\"FieldValue\" id=\"Local_session_id\" value=\"$session_id\">";

"

would have set a value for "Local_session_id"

 

 

MY intentsion is very simple, when I post the page to itself I want to carry the value to the same page, pelase help with your method or modify, please do not use session or cookie, thanks

look this must be already set echo $_POST["Local_session_id"];

because thats where the hidden fields rely so the problem is i guess not on that

page its on the page where you get this echo $_POST["Local_session_id"]; is there a form name

Local_session_id then thats causing trouble

I am doing all this because in browsers when you open many window all the window use the same session file, and one of our member was very kind to tell me to pass session file name to each page but when I do post on to itself passing cannout be done that is why i am trying to retain the faile name this way, can I give you a fuller page and will help me with the code, I am really frustrated because I am infront of my screen for hours getting no where...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.