单击提交按钮时发布值并在 if(isset()) 内回显它的简单 php 代码,但它不起作用。
<?php
if(isset($_GET['q']))
{
$q=$_GET['q'];
//echo "thisss iss qqqq".$q; this is working
$_SESSION['q']=$q;
if($q=="1")
{
?>
<form action='#'>
<tr>
<input type='text' name='txt_code' >
<input type='submit' name='code_sub' value='Showcd'>
</tr>
</form>
<?php
}
//这里我编写了当单击“showcd”按钮时回显 $bkCode 的代码,但它不起作用
<?php
if (isset($_POST["code_sub"]))
{
echo $bkCode=$_POST['txt_code']; // THIS IS NOT WORKING
}
}
?>
它甚至没有进入
if (isset($_POST["code_sub"]))
部分内部
表单的默认操作是
GET
。您必须指定您想要进行 POST :
<form action="#" method="POST">
首先,您应该设置 var,然后是一个简单的输出:
<?php
if (isset($_POST["code_sub"]))
{
$bkCode=$_POST['txt_code']; // THIS IS WORKING
echo $bkCode;
}
?>
还需要将表单方法设置为“POST”!
<form action='the_link' method="POST">
对于使用post方法:
<form action='the_link' method="POST">