$HTTP_POST_VARS naughty naughty

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sillywilly
Forum Newbie
Posts: 19
Joined: Thu May 02, 2002 5:11 pm

$HTTP_POST_VARS naughty naughty

Post 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.
samscripts
Forum Commoner
Posts: 57
Joined: Tue Apr 23, 2002 4:34 pm
Location: London, UK

Post 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
Post Reply