Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.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
HTML/PHP表单发送带有空白字段的电子邮件_Php_Html_Forms - Fatal编程技术网

HTML/PHP表单发送带有空白字段的电子邮件

HTML/PHP表单发送带有空白字段的电子邮件,php,html,forms,Php,Html,Forms,我已经在Dreamweaver中编写了一个联系人表单,并将其嵌入到Adobe Muse中。问题是表单发送的电子邮件是OK,但字段为空,只有标题。这可能是我的代码的一个问题,因为我对HTML比较在行,对PHP更是如此。PHP脚本最初是从123reg下载的,因为这是网站的托管地。Obvs我已经调整它以适应。我看过其他有类似问题的帖子,但都没有效果` 这个表单似乎工作正常,所以我可以从PHP开始 <?php $EmailFrom = "sales@trisomet.com"; $Ema

我已经在Dreamweaver中编写了一个联系人表单,并将其嵌入到Adobe Muse中。问题是表单发送的电子邮件是OK,但字段为空,只有标题。这可能是我的代码的一个问题,因为我对HTML比较在行,对PHP更是如此。PHP脚本最初是从123reg下载的,因为这是网站的托管地。Obvs我已经调整它以适应。我看过其他有类似问题的帖子,但都没有效果` 这个表单似乎工作正常,所以我可以从PHP开始

    <?php

$EmailFrom = "sales@trisomet.com";
$EmailTo = "sales@hairwraps.co.uk";
$Subject = "QuikQuote Web Enquiry";
$name = trim(stripslashes($_POST['Name']));
$email = trim(stripslashes($_POST['Email']));
$tel = trim(stripslashes($_POST['Tel']));
$textfield2 = trim(stripslashes($_POST['Postcode']));
$textarea = trim(stripslashes($_POST['Message']));
$RoofType = trim(stripslashes($_POST['Roof Type']));
$number = trim(stripslashes($_POST['Roof Length']));
$number2 = trim(stripslashes($_POST['Roof Width']));
$RadioGroup1 = trim(stripslashes($_POST['Fixings']));
$Flashing = Trim(stripslashes($_POST['Flashings']));
$panels = trim(stripslashes($_POST['Clear Panels']));
$number3 = trim(stripslashes($_POST['Quantity']));
$number4 = trim(stripslashes($_POST['Length']));

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text

$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $tel;
$Body .= "\n";
$Body .= "Postcode: ";
$Body .= $textfield2;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $textarea;
$Body .= "\n";
$Body .= "Roof Type: ";
$Body .= $RoofType;
$Body .= "\n";
$Body .= "Roof Length: ";
$Body .= $number;
$Body .= "\n";
$Body .= "Roof Width: ";
$Body .= $number2;
$Body .= "\n";
$Body .= "Fixings: ";
$Body .= $RadioGroup1;
$Body .= "\n";
$Body .= "Flashing: ";
$Body .= $Flashing;
$Body .= "\n";
$Body .= "Clear Panels: ";
$Body .= $panels;
$Body .= "\n";
$Body .= "Quantity: ";
$Body .= $number3;
$Body .= "\n";
$Body .= "Length (m): ";
$Body .= $number4;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"1;URL=index.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"1;URL=error.html\">";
}
?>

有什么明显的问题吗? 我认为我的HTML声明是可以的-

 <form action="contactform.php" method="post" class="form">

任何帮助都将是美妙的,因为它正在做我的疯狂

这是html

 <div id="formWrapper">
  <form action="contactform.php" method="post" class="form">
  <div class="container" style="width: 100%; ">
    <div class="sidebar" style="width: 365px; height:255px; margin-left:10px; float: left; ">
        <label for="textfield"><strong>Name</strong>:</label>
    <input name="textfield" type="text" required id="textfield" size="40">
  </p><br>
  <p>
    <label for="email"><strong>Email:</strong></label>
    <input name="email" type="email" required id="email" size="40">
  </p><br>
  <p>
    <label for="tel"><strong>Telephone: </strong></label>
        <input name="tel" type="tel" required id="tel" size="40">
          </p><br><p>
  <label for="textfield2"><strong>Postcode:</strong></label>
  <input name="textfield2" type="text" required id="textfield2">
          </p>
    </div>
    <div class="content" style="width:365px; height: 255px; float:right; margin-right:10px;">
         <label for="textarea"><strong>Message:</strong></label>
    <strong>
    <textarea name="textarea" rows="13" cols="40"></textarea>
    </strong></p>
    </div>

  </div>
  <div class="content3" style="width: 220px; height:110px; margin-left:10px; float: left;">
        <label for="Roof Type"><strong>Roof Type: </label>
      </strong>

      <label>
        <input name="Roof Type" type="radio" required id="RoofType_0" title="Roof Type" value="Single Slope">
        Single Slope</label>
      <label>
        <input type="radio" name="Roof Type" value="Symmetrical Apex" id="RoofType_1">
        Symmetrical Apex</label>
      <label>
        <input type="radio" name="Roof Type" value="Asymmetrical Apex" id="RoofType_2">
        Asymmetrical Apex</label>

  </div>
  <div class="content4" style="width: 215px; height: 110px; float:left; ">
  <label for="number"><strong>Roof Length (m):</strong></label>
    <input name="number" type="number" required id="number">
    <label for="number2"><strong>Roof Width (m):</strong></label>
    <input name="number2" type="number" required id="number2">
  </div>
  <div class="content5" style="width:210px; height: 110px; float:left; ">
  <label><strong>Fixings:</strong><br>

      <input name="RadioGroup1" type="radio" required id="RadioGroup1_0" value="Timber">
Timber</label>

    <label>
      <input type="radio" name="RadioGroup1" value="Light Section Steel" id="RadioGroup1_1">
      Light Section Steel</label>

    <label>
      <input type="radio" name="RadioGroup1" value="Heavy Section Steel" id="RadioGroup1_2">
      Heavy Section Steel</label>
  </div>
  <div class="content6" style="width:85px; height: 110px;float:left; ">
  <strong>Flashing:
</strong>
    <label>
      <input name="Flashing" type="radio" required id="Flashing_0" value="Yes">
      Yes</label>
    <label>
      <input type="radio" name="Flashing" value="No" id="Flashing_1">
    No</label>

  </div>
  <div class="content7" style="width:150px; margin-left: 10px; height: 90px; float:left; ">
  <label for "panels" style="font-weight:bold">Clear Panels:</strong></label>
    <label>
      <input name="panels" type="radio" required id="panels_0" value="Yes">
      Yes</label>
    <label>
      <input type="radio" name="panels" value="No" id="panels_1">
      No</label>

  </div>

  <div class="content8" style="width:100px; height: 110px; float:left;">
<label for="number3"><strong>Quantity:</strong></label>
  <input name="number3" type="number" required id="number3" style="width:80px" value="0">
  </div>
  <div class="content9" style="width:150px; height:110px;float:left;">
  <label for="number4"><strong>Length (m):</label>
  <input name="number4" type="number" required id="number4" style="width:80px" value="0">
  </div>
 <div class="submitb" style="width:190px; height:110px; float:left; ">
 <p>
 <input type="submit" name="submit" id="submit" value="Get A Quote >">
 </p>
 </div>


</form></div>

名称
电子邮件:
电话:


邮政编码:

消息:

屋顶类型: 单坡 对称顶点 不对称顶点 屋顶长度(m): 屋顶宽度(m): 固定件:
木材 轻型型钢 重型型钢 闪烁: 对 不 透明面板: 对 不 数量: 长度(m):


我似乎已经解决了自己的问题。我认为顶部的
$POST
字段是电子邮件的字段标题,而实际上它们是我表单中的字段名。呸

我似乎已经解决了自己的问题。我认为顶部的
$POST
字段是电子邮件的字段标题,而实际上它们是我表单中的字段名。呸

请显示HTML表单代码。猜猜看:您的表单字段命名正确吗?好的,这是HTML(您已收到警告!)在触发电子邮件之前,只需对
$EmailTo,$Subject,$Body
进行
打印即可,但是我需要输入什么代码?请显示HTML表单代码。猜猜看:您的表单字段命名正确吗?好的,这是HTML(您已经收到警告!)在触发电子邮件之前,只需对
$EmailTo,$Subject,$Body
执行
print\r
,请原谅我的技能不足,Sulthan,但我需要输入什么代码?