PHP 传递单选按钮值时重定向到另一个页面上的锚点 Link
PHP Redirect to Anchor Link on Another Page When Passing Radio Button Value
我正在尝试将表单值传递到另一个页面上的文本框 php。具体来说,我想在提交 page1 上的表单按钮时 link 到另一页上的文本框。
第1页:
echo '<td><input type="radio" name="myId" value= " ' . $myId . ' "></td>';
echo '<input name="mybutton" type="submit" value="Submit">';
第2页
if (isset($_POST['myId'])) {
header('Location: http://localhost/dirc/mypage.php#link');
$id = trim($_POST['myId']);
}//if no id passed
else {
$id = "";
}
然后在锚点所在的第 2 页上:
//if button clicked on Page1, redirect to here on Page2 and display the value in the textbox:
<a name="link">
<input type="textbox" value="<?php echo $myId;?>">
给出上面的内容,如果我点击我的按钮,重定向到另一个页面上的锚点有效,但是单选按钮的值没有被传递!如果我注释掉....
//header('Location: http://localhost/dirc/mypage.php#link');
myId 已通过,但重定向到锚点不起作用。
在第 1 页上,我还尝试检查 mybutton 和 myId 是否已设置:
if (isset($_POST['myId']) && ($_POST['mybutton'))
但这没有任何区别。
将 myId 传递给 Page2 没有任何问题,但是在我添加 header 位置重定向的那一刻,这会阻止数据传递吗?
感谢任何帮助。
更改为:
header('Location: http://localhost/dirc/mypage.php?myId='.$_POST['myId']);
如果您想访问它,请使用
<input type="textbox" value="<?php echo $_GET['myId'];?>">
---已编辑---
header('Location: http://localhost/dirc/mypage.php?myId='.$_POST['myId'].'#'.$_POST['myId']);
我正在尝试将表单值传递到另一个页面上的文本框 php。具体来说,我想在提交 page1 上的表单按钮时 link 到另一页上的文本框。
第1页:
echo '<td><input type="radio" name="myId" value= " ' . $myId . ' "></td>';
echo '<input name="mybutton" type="submit" value="Submit">';
第2页
if (isset($_POST['myId'])) {
header('Location: http://localhost/dirc/mypage.php#link');
$id = trim($_POST['myId']);
}//if no id passed
else {
$id = "";
}
然后在锚点所在的第 2 页上:
//if button clicked on Page1, redirect to here on Page2 and display the value in the textbox:
<a name="link">
<input type="textbox" value="<?php echo $myId;?>">
给出上面的内容,如果我点击我的按钮,重定向到另一个页面上的锚点有效,但是单选按钮的值没有被传递!如果我注释掉....
//header('Location: http://localhost/dirc/mypage.php#link');
myId 已通过,但重定向到锚点不起作用。
在第 1 页上,我还尝试检查 mybutton 和 myId 是否已设置:
if (isset($_POST['myId']) && ($_POST['mybutton'))
但这没有任何区别。
将 myId 传递给 Page2 没有任何问题,但是在我添加 header 位置重定向的那一刻,这会阻止数据传递吗?
感谢任何帮助。
更改为:
header('Location: http://localhost/dirc/mypage.php?myId='.$_POST['myId']);
如果您想访问它,请使用
<input type="textbox" value="<?php echo $_GET['myId'];?>">
---已编辑---
header('Location: http://localhost/dirc/mypage.php?myId='.$_POST['myId'].'#'.$_POST['myId']);