【问题标题】:MAILTO: Form Action Alternative? [duplicate]MAILTO:表单操作替代方案? [复制]
【发布时间】:2016-08-08 14:38:48
【问题描述】:

所以,我想在我的网站上设置一个反馈部分,并且代码在 w3school 的 TryIt Editor 中似乎可以正常工作,但由于某种原因它在我的网站上不起作用。

我发现了另一个问题,这里也是关于堆栈溢出的,非常相似,但我看到了这个answer...

mailto:表单操作依赖于浏览器和本地电子邮件客户端的良好配合。他们很少这样做,以至于 mailto: 表单操作在 WWW 上无法使用。

将其替换为发送电子邮件的服务器端程序。

有人可以举例说明这意味着什么吗?这很模糊,我假设它们的意思是 PHP,但我不太确定。

CSS:

.form-style-1 {
margin:10px auto;
max-width: 400px;
padding: 20px 12px 10px 20px;
font: 13px "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
.form-style-1 li {
  padding: 0;
    display: block;
    list-style: none;
    margin: 10px 0 0 0;
    }
.form-style-1 label{
  margin:0 0 3px 0;
  padding:0px;
  display:block;
  font-weight: bold;
  }
.form-style-1 input[type=text], 
.form-style-1 input[type=date],
.form-style-1 input[type=datetime],
.form-style-1 input[type=number],
.form-style-1 input[type=search],
.form-style-1 input[type=time],
.form-style-1 input[type=url],
.form-style-1 input[type=email],
textarea, 
select{
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  border:1px solid #BEBEBE;
  padding: 7px;
  margin:0px;
  -webkit-transition: all 0.30s ease-in-out;
  -moz-transition: all 0.30s ease-in-out;
  -ms-transition: all 0.30s ease-in-out;
  -o-transition: all 0.30s ease-in-out;
  outline: none;  
  }
.form-style-1 input[type=text]:focus, 
.form-style-1 input[type=date]:focus,
.form-style-1 input[type=datetime]:focus,
.form-style-1 input[type=number]:focus,
.form-style-1 input[type=search]:focus,
.form-style-1 input[type=time]:focus,
.form-style-1 input[type=url]:focus,
.form-style-1 input[type=email]:focus,
.form-style-1 textarea:focus, 
.form-style-1 select:focus{
  -moz-box-shadow: 0 0 8px #88D5E9;
  -webkit-box-shadow: 0 0 8px #88D5E9;
  box-shadow: 0 0 8px #88D5E9;
  border: 1px solid #88D5E9;
  }
.form-style-1 .field-divided{
  width: 49%;
  }
.form-style-1 .field-long{
  width: 100%;
  }
.form-style-1 .field-select{
  width: 100%;
  }
.form-style-1 .field-textarea{
  height: 100px;
  }
.form-style-1 input[type=submit], .form-style-1 input[type=button]{
  background: #4B99AD;
  padding: 8px 15px 8px 15px;
  border: none;
  color: #fff;
  }
.form-style-1 input[type=submit]:hover, .form-style input[type=button]:hover{
  background: #4691A4;
  box-shadow:none;
  -moz-box-shadow:none;
  -webkit-box-shadow:none;
  }
.form-style-1 .required{
  color:red;
  }

HTML:

<html>
  <head>
  </head>
  <body>
    <form action="MAILTO:feedback@itzjavacraft.tk" method="post" enctype="text/plain">
      <ul class="form-style-1">
        <li>
          <label>
            Full Name <span class="required">*</span>
          </label>
          <input type="text" name="field1" class="field-divided" placeholder="First"/>&nbsp;
          <input type="text" name="field2" class="field-divided" placeholder="Last"/>
        </li>
        <li>
          <label>
            Email <span class="required">*</span>
          </label>
          <input type="email" name="field3" class="field-long" />
      </li>
      <li>
        <label>
          Subject
        </label>
        <select name="field4" class="field-select">
          <option value="Feedback">Feedback</option>
          <option value="Suggestion">Suggestion</option>
          <option value="General">General</option>
        </select>
      </li>
      <li>
        <label>
          Your Message <span class="required">*</span>
        </label>
        <textarea name="field5" id="field5" class="field-long field-textarea"></textarea>
      </li>
      <li>
        <input type="submit" value="Submit" />
      </li>
    </ul>
  </form>
<body> 

【问题讨论】:

    标签: php html css


    【解决方案1】:

    将其替换为发送电子邮件的服务器端程序。

    意思是,mailto不行,你需要使用任何服务器端 处理电子邮件的程序,如 PHP 邮件功能。 示例:

    <?php
      $to      = 'nobody@example.com';
      $subject = 'the subject';
      $message = 'hello';
      $headers = 'From: webmaster@example.com';
      mail($to, $subject, $message, $headers);
    ?>
    

    PHP.net了解有关PHP邮件功能的详细信息 您可以从表单中检索数据并在 PHP 的邮件功能中使用。

    【讨论】:

    • 这只是部分答案,并不能完全解决问题;你在他们的代码中遗漏了一些东西。
    猜你喜欢
    • 2019-09-11
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多