Page 1 of 1

$HTTP_POST_VARS naughty naughty

Posted: Tue May 07, 2002 1:35 pm
by sillywilly

Code: Select all

<?php 
while (list($k, $v) = each($HTTP_POST_VARS)) 
&#123; 
print("<input type=hidden name=&quote;$k&quote; value=&quote;".htmlspecialchars($v)."&quote;>\n"); 
&#125; 
?>

There is one problem, i do not require it to print certain variables as hidden fields. Thus i need a way to exclude certain passed variables from being added as hidden fields. For example i do not want:

either:
<input type="submit" name="Submit" value="Submit">
or:
<input type="hidden" name="stage" value="3">

added as hidden fields.

Could you suggest a way to exclude variables from being added.

Posted: Tue May 07, 2002 3:27 pm
by samscripts
just don't print the variables that you don't want:

Code: Select all

<?php 
$excludeus = array("submit", "stage");
while (list($k, $v) = each($HTTP_POST_VARS)) 
&#123; 
   if( !in_array($k, $excludeus) )&#123;
      print("<input type=hidden name=&quote;$k&quote; value=&quote;".htmlspecialchars ($v)."&quote;>\n"); 
   &#125;
&#125; 
?>
hope this is what you want,

sam