Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 搜索表单的空值_Php_Html_Forms - Fatal编程技术网

Php 搜索表单的空值

Php 搜索表单的空值,php,html,forms,Php,Html,Forms,我想从我正在开发的页面中搜索地址簿。通讯簿是另一页的内容,此页上通讯簿的url为。此通讯簿有自己的搜索字段,我将在我的页面中使用该字段。 我已填写以下搜索表: <form action="http://example.com/start.php" method="post" target="_blank"> <div> <input type="hidden" value="adress" name="cmd" /> <input id = "adr

我想从我正在开发的页面中搜索地址簿。通讯簿是另一页的内容,此页上通讯簿的url为。此通讯簿有自己的搜索字段,我将在我的页面中使用该字段。 我已填写以下搜索表:

<form action="http://example.com/start.php" method="post" target="_blank">
<div>

<input type="hidden" value="adress" name="cmd" /> 
<input id = "adressinput" name="search" type="text" title="Search in the adress book [ctrl-f]" accesskey="f" value="adress book" />
<input id="refresh" title="refreshnow" name="refresh" type="image" src="icons/Downloads/arrow-circle-single.png" class="iconbutton"/>                               

</div>
</form>

问题是,当我在表单的文本框中写入内容,然后单击refreshnow图标时,页面(地址簿)会显示出来,但是该页面的搜索字段仍然有一个空值,当然,我不会得到任何结果

这不是我的第一张搜索表。我写过类似的表格,但它们都有效,所以我不知道为什么它不起作用

  • 从表单中删除目标属性,地球上绝对没有理由再使用弹出窗口了
  • 2.)您使用的脚本语言是什么?如果PHP正在引用
    $\u POST['search']
    ,或者您是无意中引用了
    $\u GET['search']

    这一行

    <input id = "adressinput" name="search" type="text" title="Search in the adress book [ctrl-f]" accesskey="f" value="adress book" />
    
    其中,
    $\u POST['search']
    将包含输入的搜索词的值(一旦提交了该表单即为)


    这是查询数据库以获得与其内容匹配的搜索结果所需的值。

    您不能只回显
    $\u POST
    变量,您需要使用
    isset()
    首先。
    虽然我认为你的答案可能更准确,但操作从一开始就不太清楚。@约翰,不确定你的意思,我已经在用
    isset
    检查
    POST
    变量了?如果你不检查变量,它会发出一个小警告。有时黑客会试图忽略GET/POST变量当他们试图确定潜在的攻击向量时,服务器会报告什么错误。但是,你的代码应该只返回HTTP 4xx错误中的唯一内容,并且记录每个PHP错误,不管多么无关紧要。@约翰和马丁卡林对你的答案非常感谢。希望它能起作用!不幸的是,使用POST方法并没有改变任何东西。我使用PHP作为脚本语言,您是对的,我不需要target属性。只有我通过搜索才能更好地看到正在发生的事情。
    <input id="adressinput" name="search" type="text" title="Search in the address book [ctrl-f]" accesskey="f" value="<?php echo $_POST['search']; ?>" />
    
    if (isset($_POST['search'])) {
        ?>
        <input id="adressinput" name="search" type="text" title="Search in the address book [ctrl-f]" accesskey="f" value="<?php echo $_POST['search']; ?>" />
        <?php
    } else {
        ?>
        <input id="adressinput" name="search" type="text" title="Search in the address book [ctrl-f]" accesskey="f" value="adress book" />
        <?php
    }  
    
    if (isset($_POST['search'])) {
        $value = $_POST['search'];
    } else {
        $value = 'adress book'
    }
    
    <input id="adressinput" name="search" type="text" title="Search in the address book [ctrl-f]" accesskey="f" value="<?php echo $value; ?>" />