Submitting Form Replaces Constant Get Information That Is Needed For The Page
I'm learning php and I've got to say I've googled everywhere and I'm stuck :( My question is, in other words, how can I get new variables added to previous variables on the page? I
Solution 1:
Instead of submitting to an action
URL with part of the query string already filled out, use a hidden input field to hold the values of the variables you want to be fixed. See if you can get your PHP script to generate a form like this:
<formaction="getvartest.php"method="get"><inputtype="hidden"name="orgvar"value="12345" /><selectname="varselection"><optionvalue="selection1">selection1</option><optionvalue="selection2">selection2</option></select><inputtype="submit" /></form>
Perhaps something like:
<inputtype="hidden"name="orgvar"value="<?= htmlspecialchars($_GET['orgvar']) ?>" />
(The htmlspecialchars()
call escapes characters like <
, &
, and "
just in case there are any of these in orgvar
.)
Or if you wanted to save every query parameter you could use a generic loop like:
<?phpforeach ($_GETas$name => $value) { ?><inputtype="hidden"name="<?= htmlspecialchars($name) ?>"value="<?= htmlspecialchars($value) ?>" /><?php } ?>
Post a Comment for "Submitting Form Replaces Constant Get Information That Is Needed For The Page"