[英]How to call php variable input text from another Php page
我的问题是如何调用所选用户的输入值,该值已由另一个php的php代码显示。
正常的简单方法是通过这种方式获取输入
$calendar_id_val = $_GET['calendar_id'];
现在它不起作用:
例如Show.php,我有一种形式显示数据库中的值,并使用While循环使用php变量显示结果。
<input name="calendar_id" value="<?php echo $calendar_id;?>">
当用户提交该表格时,我将携带这些用户选择的值并执行insert.php
在输入中执行echo时,请使用echo $ calendar_id_val
您应该使用如下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'];
这回答了你的问题了吗?
<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();
我建议这样的$_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'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.