如何从另一个Php页面调用php变量输入文本

时间:2013-08-05 06:27:37

标签: php variables input session-variables

我的问题是如何调用所选用户的输入值,该输入值由另一个php的php代码显示。

我们以这种方式获得输入的正常简单方法

 $calendar_id_val = $_GET['calendar_id']; 

现在它无法正常工作:

例如Show.php,我有一个表单显示数据库中的值,并使用While循环显示php变量的结果。

<input name="calendar_id" value="<?php echo $calendar_id;?>">

当用户提交该表格时,我将携带这些用户选择的值并执行insert.php

4 个答案:

答案 0 :(得分:0)

当您在输入中使用echo时,使用echo $ calendar_id_val

答案 1 :(得分:0)

您应该使用form之类的,

<form action="insert.php" method="get">
  <input type="text" name="calendar_id" value="<?php echo $calendar_id;?>"/>
  <input type="submit" name="submit_id" value="Insert"/>
</form>

<强> Insert.php

echo $calendar_id_val = $_GET['calendar_id']; 

答案 2 :(得分:0)

这会回答你的问题吗?

<form action="insert.php" method="GET">
    <input name="calendar_id" value="<?php echo $calendar_id;?>">
</form>

如果您想将用户重定向回show.php,请将其添加到insert.php脚本的末尾

header('Location: show.php');
exit();

答案 3 :(得分:0)

我建议$_POST var如下:

<form action="insert.php" method="POST">
  <input type="text" name="calendar_id" value="<?php echo $calendar_id;?>" />
  <input type="submit" name="submit" value="Submit" />
</form>

insert.php文件:

echo $calendar_id = $_POST['calendar_id'];