0

我的代码如下

<form method="post" action="raf_details.php?raf=<? echo $_POST['raf']; ?>">
<table width="60%" border="0" cellspacing="2" cellpadding="2" align="center">
  <tr style="background-color:#C1C1C1" align="center">
    <td>RAF</td>
    <td>Phone Number</td>
    <td>Search</td>
  </tr>
  <tr align="center" bgcolor="#E8F8FF" style="background-color:#E1E1E1">
    <td><input type="text" name="raf" id="raf" value="<?php echo $_POST['raf'];?>" /></td>
    <td><input type="text" name="phone" id="phone" value="<?=$_POST['phone'];?>"/></td>
    <td><input type="image" src="../images/btnFind.png" id="find" name="find"  /></td>
  </tr>
</table>
</form>

但它并没有在我的 url 显示的 url 中显示 $_POST['raf'] 值

http://localhost:8888/ample/payment/raf_details.php?raf=
4

3 回答 3

2

您需要get为您的表单使用方法,例如

<form method="get" action="raf_details.php">

然后在提交您的表单时,网址会像

/raf_details.php?raf=somthing
于 2013-09-11T05:55:32.110 回答
0

是的,这是真的。但是,您可以从 $_GET['raf'] 访问它。您可以同时发送 get 和 post 参数。
但一个好的实践解决方案是:

<!-- remove the raf from the action -->
<form method="post" action="raf_details.php">
<!-- ****************add this line ****************** -->
    <input type="hidden" name="raf" value="<? echo $_POST['raf']; ?>" />
<table width="60%" border="0" cellspacing="2" cellpadding="2" align="center">
  <tr style="background-color:#C1C1C1" align="center">
    <td>RAF</td>
    <td>Phone Number</td>
    <td>Search</td>
  </tr>
  <tr align="center" bgcolor="#E8F8FF" style="background-color:#E1E1E1">
    <td><input type="text" name="raf" id="raf" value="<?php echo $_POST['raf'];?>" /></td>
    <td><input type="text" name="phone" id="phone" value="<?=$_POST['phone'];?>"/></td>
    <td><input type="image" src="../images/btnFind.png" id="find" name="find"  /></td>
  </tr>
</table>
</form>
于 2013-09-11T05:55:47.090 回答
0

我们可以使用 GET 和 POST 发送参数。如果要在 url 中传递变量,请使用 GET 方法。

<form method="get" action="raf_details.php">
于 2013-09-11T06:00:48.190 回答