Home How to store variable value after clicking "Submit"?
Reply: 0

How to store variable value after clicking "Submit"?

user2169
1#
user2169 Published in April 25, 2018, 12:35 pm

Solution:

<?php
    $typeAnag = filter_input ( INPUT_GET, 'typeAnag', FILTER_SANITIZE_STRING );
    $filter = filter_input ( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
    ?>

    <nav class="navbar navbar-light bg-light">
        <form class="form-inline">
            <button class="btn btn-sm align-middle btn-outline-secondary"
                type="submit" name="typeAnag" value="all">All</button>
        </form>

        <form class="form-inline pull-xs-right" >
            <input type="filter" name="filter" id="filter"
                class="form-control mr-sm-2" placeholder="Filter...">
<input type="hidden" name="typeAnag" value="<?=$typeAnag?>">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Filtra</button>
        </form>
    </nav>

I have this php page with two forms:

<?php
$typeAnag = filter_input ( INPUT_GET, 'typeAnag', FILTER_SANITIZE_STRING );
$filter = filter_input ( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
?>

<nav class="navbar navbar-light bg-light">
    <form class="form-inline">
        <button class="btn btn-sm align-middle btn-outline-secondary"
            type="submit" name="typeAnag" value="all">All</button>
    </form>

    <form class="form-inline pull-xs-right" >
        <input type="filter" name="filter" id="filter"
            class="form-control mr-sm-2" placeholder="Filter...">
        <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Filtra</button>
    </form>
</nav>

When I click the submit form "typeAnag" I obtain in the url ../index.php?typeAnag=all and for the form "filter" ../index.php?filter=word

But I would like to store the value typeAnag=all and composite my url like this: ../index.php?typeAnag=all&filter=word

But when I click the form, I lost the variable value of the previous submit.

I try to use $_SESSION but doesn't work.

Any help would be appreciated

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.365748 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO