我遇到的第一个问题是,我想在 index.php 上通过表单向用户提问,并且当按下提交时,它会更新 jcart.php 上的会话变量。使用下面的当前代码,当我稍后调用会话变量时,现在可以找到它,所以我假设我刚才的代码无法正常工作。
第二个问题是当我按下提交时,它会将我带到 jcart.php 是否有办法避免这种情况或让它返回。
在我的 index.php 上,我有一个表格:
<form action="jcart/jcart.php" method="post">
<input type="text" name="example" id="example" />
<input type="submit" name="submit" value="Submit" />
</form>
在 Jcart.php 上:
$_SESSION['example'] = $_POST['example'];
然后在页面上,我在鸡尾酒会.php 上调用它
<?php
include_once('jcart/jcart.php');
session_start();
?>
<input type="hidden" name="my-item-id" value="<?php echo $_SESSION['example'];?>" />
谢谢你的帮助。