Get A Variable

Why can't I get this to work?  
This is a database of veteran's information.  In one table we store all the wars that veterans might have been involved in.  We then build a form that provides a drop down to select a war.  That works fine.  The problem is that when they click SUBMIT, I am not getting the name of the war in the next script.  Any ideas?  Here's the code:


<td width="50%">&nbsp;By Battle/Campaign</td>
	          <td width="50%">&nbsp;By Last Name</td>
		    </tr>
	        <tr></td>
			   <form name="srchid" method="POST" action="admin_veteran_2.php" onsubmit="return submitform('srchid2', 0);">
		      
<td width="15%" class="tdinput">
                  <select size="1" name="srchid2">
				   <?
				   //Display Generations from table
				   foreach($schools as $school){
				   ?>
                    <option value="<? echo $school->ID; ?>"><? echo $school->War; ?></option>
				   <?
				   };
				   ?>
                  </select>
                  <input type="submit" value="srchid2" name="submit" class="frmbut">
                  <input type="hidden" name="action" value="srchid">
	          </td>
			  </form>

Open in new window

LVL 1
dougp23Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roger BaklundCommented:
The code you posted seems ok, maybe the error is in admin_veteran_2.php. How do you fetch the submitted variable?
0
dougp23Author Commented:
In admin_veteran_2.php, I have this:
(The first chunk is the function get_param and then the next line is where I try to grab the paramter).  I guess my issue is, I'm not sure WHERE I am storing the parameter from the SELECT.

If I echo $whatis I get nothing.
function get_param($param_name)
{
  global $HTTP_POST_VARS;
  global $HTTP_GET_VARS;
 
  $param_value = "";
  if(isset($HTTP_POST_VARS[$param_name])) {
    $param_value = $HTTP_POST_VARS[$param_name];
  } else if(isset($HTTP_GET_VARS[$param_name])) {
    $param_value = $HTTP_GET_VARS[$param_name];
  }
  return $param_value;
}
 
$whatis=get_param("$srchid2");

Open in new window

0
Roger BaklundCommented:
First, the call to get_param() should be like this, without the $ character:

$whatis=get_param("srchid2");

Second, $HTTP_POST_VARS and $HTTP_GET_VARS are deprecated, and not supported on all servers. Do like this instead, this will fetch both POST and GET variables:

$whatis=isset($_REQUEST['srchid2'])?$_REQUEST['srchid2']:'';
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dougp23Author Commented:
Well that worked!  I guess I must be on a server where those functions are deprecated.  Now I need to do some real digging since I have quite a few PHP apps where I used that function (get_param).  Hopefully they replaced the other calls with something else after deprecating them.
0
Roger BaklundCommented:
>> Hopefully they replaced the other calls with something else after deprecating them.

$HTTP_POST_VARS is replaced by $_POST and $HTTP_GET_VARS is replaced by $_GET, both are "superglobals", which means they are automatically available within functions without using the "global" keyword.

http://php.net/manual/en/reserved.variables.php
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.