PHP表单数据没有收集

时间:2017-11-26 23:31:44

标签: php forms

我在bootstrap中创建一个简单的表单。我对php并不熟悉,但是根据我在网上找到的内容,我提出了以下内容。当用户点击我的提交按钮时,会发送一封电子邮件,我收到的电子邮件中会显示所有表单字段,但不会收集数据。我做错了什么?下面的PHP和表格可以在http://esdclient.com/formb/masterform.html

查看
<?php
/* Set e-mail recipient */
$myemail  = "ken@elschwartzodesign.com";

/* Check all form inputs using check_input function */
$Name    = check_input($_POST['Name']);
$Last  = check_input($_POST['Last']);
$City   = check_input($_POST['City']);
$State = check_input($_POST['State']);
$Zip = check_input($_POST['Zip']);



/* Let's prepare the message for the e-mail */
$message = "Hello!

Your contact form has been submitted by:

Name: $Name
Last: $Last
City: $City
State: $State
Zip: $Zip
";

/* Send the message using mail() function */
mail($myemail, $subject, $message);

/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
exit();

/* Functions we used */
function check_input($data, $problem='')
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($problem && strlen($data) == 0)
    {
        show_error($problem);
    }
    return $data;
}

function show_error($myError)
{
?>
    <html>
    <body>

    <b>Please correct the following error:</b><br />
    <?php echo $myError; ?>

    </body>
    </html>
<?php
exit();
}
?>

1 个答案:

答案 0 :(得分:0)

enctype错误,请尝试enctype =&#34; multipart / form-data&#34;