checked checkbox will remain through pagination

前端 未结 1 1177
半阙折子戏
半阙折子戏 2021-01-22 03:25

i am doing a php script wherein I need to remember the checked checkbox and save it all the database. Unfortunately, my code save only the current page where I checked the check

相关标签:
1条回答
  • 2021-01-22 04:04

    Ugg... way too much code to look through.

    The short answer, however, is that you pass values from one form to another using <input type-"hidden"...> markup.

    Warning, code type free-hand

    Page1.php

    <form action="page2.php">
      <div>
        <input type="checkbox" name="test1">
      </div>
    </form>
    

    Page2.php

    <?php
      if (is_set($_REQUEST["test1"])) {
        $test1 = $_REQUEST["test1"];
      } else {
        $test1 = false;
      }
    
    <form action="page3.php">
      <div>
        <input type="hidden" name="test1" value="<?php echo $test1 ?>">
      </div>
    </form>
    

    Page3.php

    <?php
        $test1 = $_REQUEST["test1"];
    ?>
    
    0 讨论(0)
提交回复
热议问题