oceans Posted July 3, 2007 Share Posted July 3, 2007 Dear People, I am posting a form onto itself to verify input entry, I can get the value of text box and combo box, but how can I get the value of a “variable” (don’t use cookie or session)? That is if I use if ($_POST["$Variable"]!=1){} Thanks. Quote Link to comment Share on other sites More sharing options...
oceans Posted July 3, 2007 Author Share Posted July 3, 2007 Can any one please help me, thanks. Quote Link to comment Share on other sites More sharing options...
no_one Posted July 3, 2007 Share Posted July 3, 2007 Not sure if I totally understand what you need, but you could use a hidden field in the form: <form> <input type='hidden' name='variable' value='some_value'> </form> Is this what you need? Quote Link to comment Share on other sites More sharing options...
oceans Posted July 3, 2007 Author Share Posted July 3, 2007 Thanks, I am trying, give me a while Quote Link to comment Share on other sites More sharing options...
oceans Posted July 3, 2007 Author Share Posted July 3, 2007 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 Quote Link to comment Share on other sites More sharing options...
no_one Posted July 3, 2007 Share Posted July 3, 2007 Oh, $flag = $_POST['Flag']; ??? Quote Link to comment Share on other sites More sharing options...
oceans Posted July 3, 2007 Author Share Posted July 3, 2007 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? Quote Link to comment Share on other sites More sharing options...
oceans Posted July 3, 2007 Author Share Posted July 3, 2007 <?PHP if ($_POST["Flag"]==1) { bla bla bla } else { bla bla bla $Flag=1; echo "<input name=\"Flag\" type=\"hidden\" value=\"$Flag\">"; } ?> Quote Link to comment Share on other sites More sharing options...
no_one Posted July 3, 2007 Share Posted July 3, 2007 What else is there to this code? Or is that it? Quote Link to comment Share on other sites More sharing options...
oceans Posted July 3, 2007 Author Share Posted July 3, 2007 Dear Friend, The page is long thus I did an extract for you. Actually there is nothing else out of this <?PHP ?> Quote Link to comment Share on other sites More sharing options...
oceans Posted July 11, 2007 Author Share Posted July 11, 2007 Dear People, I tried to use one of the members advice but I can't get to post the value is there any thing wrong? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 dear friend its me again and can i see your form Quote Link to comment Share on other sites More sharing options...
oceans Posted July 11, 2007 Author Share Posted July 11, 2007 give me 2 min i am trimming else this page will be miles long Quote Link to comment Share on other sites More sharing options...
oceans Posted July 11, 2007 Author Share Posted July 11, 2007 <?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] Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 where can i find this $_POST["Flag"] or the form name flag Quote Link to comment Share on other sites More sharing options...
oceans Posted July 11, 2007 Author Share Posted July 11, 2007 Sorry, The Flag was on the old message, please ignore "Flag" and take "Local_session_id" thanks.. please go through my new code and you will find when I echo the post does not come out.. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 echo $_POST["Local_session_id"]; echo "<input name=\"Local_session_id\" type=\"hidden\" class=\"FieldValue\" id=\"Local_session_id\" value=\"$session_id\">"; which is not comming out Quote Link to comment Share on other sites More sharing options...
oceans Posted July 11, 2007 Author Share Posted July 11, 2007 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 Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 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 Quote Link to comment Share on other sites More sharing options...
oceans Posted July 11, 2007 Author Share Posted July 11, 2007 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.