Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.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 表单在提交时返回值1_Php_Jquery_Html_Forms - Fatal编程技术网

Php 表单在提交时返回值1

Php 表单在提交时返回值1,php,jquery,html,forms,Php,Jquery,Html,Forms,我的标签中有一些内容和一个表。提交时,当Iecho来自表单的post值时,它会针对每个输入的值显示值1 echo"<pre>";print_r($_POST['Invoice']);die; 这让我感到惊讶,我想知道为什么会发生这种情况? 即使我注释掉了所有CSS和JavaScript链接库/文件,仍然会返回1 HTML: <div id="page-wrap"> <form method="post" action="save_view.php">

我的
标签中有一些内容和一个表。提交时,当I
echo
来自表单的post值时,它会针对每个输入的值显示值
1

echo"<pre>";print_r($_POST['Invoice']);die;
这让我感到惊讶,我想知道为什么会发生这种情况? 即使我注释掉了所有CSS和JavaScript链接库/文件,仍然会返回
1

HTML

<div id="page-wrap">
    <form method="post" action="save_view.php"> <textarea id="header">INVOICE</textarea>
        <div id="identity">
            <div> <img id="image" src="images/logo_1.png" alt="logo" /> </div>
        </div>
        <div style="clear:both"></div>
        <div id="customer">
            <table id="meta">
                <tr>
                    <td class="meta-head">Invoice #</td>
                    <td> <input name="Invoice" type="text" /> </td>
                </tr>
                <tr>
                    <td class="meta-head">Customer Name</td>
                    <td> <input name="cname" type="text" /> </td>
                </tr>
                <tr>
                    <td class="meta-head">Paid Date</td>
                    <td> <input name="pdate" type="text" /> </td>
                </tr>
                <tr>
                    <td class="meta-head">Sales Person</td>
                    <td> <input name="sperson" type="text" /> </td>
                </tr>
            </table>
        </div> <input name="submit" type="submit" value="Submit" /> </form>
</div>
isset()总是返回true或false,像这样回显您的数据

if(isset($_POST['submit']))
{
    $invoice = isset($_POST['Invoice']) ? $_POST['Invoice'] : '';
    echo ($invoice);
    die();
}
echo”“;打印($_POST[‘发票’]);死亡
isset()总是返回true或false,像这样回显您的数据

if(isset($_POST['submit']))
{
    $invoice = isset($_POST['Invoice']) ? $_POST['Invoice'] : '';
    echo ($invoice);
    die();
}
echo”“;打印($_POST[‘发票’]);死亡

确定变量是否已设置且不为空

要获得价值,你必须像这样使用

if(isset($_POST['submit']))
{
    $invoice = isset($_POST['Invoice']) ? $_POST['Invoice'] : '';
    echo ($invoice);
    die();
}
你每次都是对的,这就是你每次只有1的原因

确定变量是否已设置且不为空

要获得价值,你必须像这样使用

if(isset($_POST['submit']))
{
    $invoice = isset($_POST['Invoice']) ? $_POST['Invoice'] : '';
    echo ($invoice);
    die();
}

每次都是真的,这就是每次只得到1的原因

isset
返回一个布尔值

$invoice = 1 //variable exist

$invoice =0 //variable not exist

isset
返回一个布尔值

$invoice = 1 //variable exist

$invoice =0 //variable not exist
方法用于确定是否存在变量

因此,当您执行
$invoice=isset($_POST['invoice'])

试一试

方法用于确定是否存在变量

因此,当您执行
$invoice=isset($_POST['invoice'])

试一试


您要求回显isset()的结果,这是一个布尔值。因为您的值为true=>它会回显1,所以您要求回显isset()的结果,这是一个布尔值。因为你的值是真的=>它会回响1ohhhh!!Thanxxxxxxohhhhh!!Thanxxxxxxohhhhh!!Thanxxxxxxohhhhh!!Thanxxxxxxohhhhh!!Thanxxxxxxohhhhh!!XXXXXXX