如何在另一个页面中获取foreach值


How do I get the foreach value in another page?

表单提交后,我将获得checkbox值,并在$segment值上存储在$segment.Based中。我向form.From显示该表单,我将向下一页(final.php)发送一些值,而不是分段值,但我想在此处获得$segment值,为此我必须做什么?

注意:$segment值是数组。有人能帮我吗

此处为教程主题.php

<?php
    if(isset($_POST['submit']))
    {
      $segment=$_POST['segment'];
      echo $segment;
    }
   ?>
    <form name="f1" action="tutorsubject.php" method="post">
    <p>Teaching segment
    <input type="checkbox" name="segment[]" value="Engineering">Engineering
    <input type="checkbox" name="segment[]" value="Technology">Technology
    <input type="checkbox" name="segment[]" value="Dances">Dance
    </p>
    <input type="submit" name="submit" value="submit">
    </form>

现在

    <form name="f1" action="final.php" method="post"/>
   Name:<input type="Text" name="name" value=""/>
    <input type="submit"  name="Submit" value="submit"/>
    </form>

Final.php在这里我得到了基于Final.php的值。在Final.php中,我想获得我必须做的的$segment值

为什么不使用session:

$_SESSION["segment"] = $segment;

并在您的final.php页面中阅读:

print_r($_SESSION["segment"]);

希望这对你有帮助。