[英]How to get text on same page after form submit using href?
I am submitting a form using an href link via POST method. 我正在通过POST方法使用href链接提交表单。 When I submit the form I am not able to get the value of the PHP variable. 提交表单时,我无法获取PHP变量的值。
Here is my code 这是我的代码
if(($_POST)) {
$users1 = $_POST['cityname'];
echo $users1;
echo "shakti";
}
<td align="center">
<form action="searchresult.php" method="POST">
<a href="#" style="text-decoration:none;" onclick="parentNode.submit();" name="an">
</form>
<?php echo $row['city']; ?>
<input type="text" value="<?php echo $row['city'];?>" name="cityname">
</a>
</td>
How can I achieve my desired output? 如何获得所需的输出?
Thanks! 谢谢!
A Form element inside an anchor tag is invalid HTML . 锚标记内的Form元素是无效的HTML 。
if(($_POST)) {
$users1 = $_POST['cityname'];
echo $users1;
echo "shakti";
}
<td align="center">
<form action="searchresult.php" name="form1" method="POST">
<?php echo $row['city']; ?>
<input type="text" value="<?php echo $row['city'];?>" name="cityname">
<a href="#" style="text-decoration:none;" onclick="javascript:document.form1.submit();" name="an">SUBMIT</a>
</form>
</td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.