繁体   English   中英

无法将参数传递给php形式?

[英]unable to pass a parameters to php in a form?

我有html表单,但我无法将隐藏参数传递给下一页。我想将隐藏的clientid传递给下一页,但我无法传递。

我的表格

<form action = "clientpricelistexport/exp_to_excel.php" method = "post">

<input type="hidden" name="clientid" id="clientid" value="<?echo $clientid;?>" >

<table  id="CPH_GridView1">

    <tbody >
<?php   

  $dbHost = 'localhost'; // usually localhost
 $dbUsername = 'xxx';
 $dbPassword = 'xxxx';
  $dbDatabase = 'xxxx';
  $db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
  mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");
$clientid=$_GET['clientid'];
if($clientid!=""){
$sql = mysql_query("SELECT `clientid` , `clientname`
FROM `client_list`
WHERE `clientid` = '$clientid'");
while($rows=mysql_fetch_array($sql))
{
if($alt == 1)
        {
           echo '<tr class="alt">';
           $alt = 0;
        }
        else
        {
           echo '<tr>';
           $alt = 1;
        }

echo ' 
        <td id="CPH_GridView1_clientid" style="width:140px" class="edit clientid '.$rows["id"].'">'.$rows["clientid"].'</td>
        <td id="CPH_GridView1_clientname" style="width:160px" class="edit clientname '.$rows["id"].'">'.$rows["clientname"].'</td>      

                <td style="width:65px" class="deleteclientlist '.$rows["id"].'"></td>

        </tr>';


}
}
?>
</tbody>
</table>

<input type="submit" value="Export"  class="export">

   </form>

我试图像这样在下一页中打印它。

$clientid=$_GET['clientid'];
print $clientid;

但它没有打印出来,任何人告诉我我要去哪里错了,谢谢。

您正在使用<form action = "exp_to_excel.php" method = "post">作为方法“ POST”,但是使用“ GET”访问值

尝试

$clientid=$_POST['clientid'];
print $clientid;

您正在使用method =“ POST”。 要使用此方法从表单中检索数据,您必须使用:

$clientid = $_POST['clientid']

$ _POST

要么

$clientid = $_REQUEST['clientid']

$ _REQUEST

用户$ _REQUEST ['clientid'],它将处理get和post请求。

您可以在表单中指定方法发布,然后从$ _GET获取它。 更改为

$clientid=$_POST['clientid'];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM