【问题标题】:How to call php variable input text from another Php page如何从另一个 PHP 页面调用 php 变量输入文本
【发布时间】:2013-08-05 18:50:03
【问题描述】:

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

我们以这种方式获取输入的普通简单方式

 $calendar_id_val = $_GET['calendar_id']; 

现在它不工作了:

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

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

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

【问题讨论】:

  • 你的form.get或者post是什么类型的..??能不能显示html..??
  • 你的表单看起来像这样
    ?如果在您的表单中使用了 get,那么您应该在插入页面中使用 $_GET,如果您在表单中使用帖子,那么您应该在 insert.php 中使用 $_POST 变量

标签: php variables input session-variables


【解决方案1】:

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

【讨论】:

  • 我在第二个 php "insert.php" 处调用 $calendar_id_val,结果未显示。
【解决方案2】:

你应该使用formlike,

<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>

插入.php

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

【讨论】:

  • 我的表单函数正在使用
    我输入的方式与 echo $calendar_id_val = $_GET['calendar_id'];结果不显示
  • 尝试print_r($_REQUSET),在回显之前,还要检查是否继续insert.php
【解决方案3】:

这能回答你的问题吗?

<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();

【讨论】:

  • 我知道如何重定向回来,这不是我的问题
【解决方案4】:

我建议像这样$_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>

插入.php 文件:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-27
    • 1970-01-01
    • 1970-01-01
    • 2019-03-06
    • 1970-01-01
    • 2020-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多