formsubmit收到的消息即使name=””也是空白的。

huangapple go评论80阅读模式
英文:

formsubmit messages recieved are blank even with name=""

问题

这是我的代码。正如你所看到的,我在我想要发送给自己的所有字段上都有name="",但当我填写表单并检查我的电子邮件时,它是空白的。

<div class="col-lg-6">
  <div class="contact-form">
    <form action="https://formsubmit.co/myemailwashere@gmail.com" method="POST" enctype="text/plain">
      <input type="hidden" name="_next" value="https://mywebsite..app/thanks.html">
      <div class="form-group mb-4 pb-2">
        <label for="exampleFormControlInput1" class="form-label">Full Name</label>
        <input type="text" class="form-control shadow-none" name="name" id="contact_name">
      </div>
      <div class="form-group mb-4 pb-2">
        <label for="exampleFormControlInput1" class="form-label">Email address</label>
        <input type="email" class="form-control shadow-none" name="email" id="contact_email">
      </div>
      <div class="form-group mb-4 pb-2">
        <label for="exampleFormControlTextarea1" class="form-label">Write Message</label>
        <textarea name="message" class="form-control shadow-none" id="exampleFormControlTextarea1" placeholder="message" rows="3"></textarea>
      </div>
      <button class="btn btn-primary w-100" type="submit">Send Message</button>
    </form>
  </div>
</div>

我尝试过使用一次性电子邮件服务,但仍然无法使我的代码工作。有人能帮我解决这个问题吗?

英文:

Here is my code. As you can see, I have the name="" on all of the fields I want to be sent to me, but when I fill out the form and check my email it is blank.

            &lt;div class=&quot;col-lg-6&quot;&gt;
              &lt;div class=&quot;contact-form&quot;&gt;
                &lt;form action=&quot;https://formsubmit.co/myemailwashere@gmail.com&quot; method=&quot;POST&quot; enctype=&quot;text/plain&quot;&gt;
                  &lt;input type=&quot;hidden&quot; name=&quot;_next&quot; value=&quot;https://mywebsite..app/thanks.html&quot;&gt;
                  &lt;div class=&quot;form-group mb-4 pb-2&quot;&gt;
                    &lt;label for=&quot;exampleFormControlInput1&quot; class=&quot;form-label&quot;&gt;Full Name&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control shadow-none&quot; name=&quot;name&quot; id=&quot;contact_name&quot;&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group mb-4 pb-2&quot;&gt;
                    &lt;label for=&quot;exampleFormControlInput1&quot; class=&quot;form-label&quot;&gt;Email address&lt;/label&gt;
                    &lt;input type=&quot;email&quot; class=&quot;form-control shadow-none&quot; name=&quot;email&quot; id=&quot;contact_email&quot;&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group mb-4 pb-2&quot;&gt;
                    &lt;label for=&quot;exampleFormControlTextarea1&quot; class=&quot;form-label&quot;&gt;Write Message&lt;/label&gt;
                    &lt;textarea name=&quot;message&quot; class=&quot;form-control shadow-none&quot; id=&quot;exampleFormControlTextarea1&quot; placeholder=&quot;message&quot; rows=&quot;3&quot;&gt;&lt;/textarea&gt;
                  &lt;/div&gt;
                  &lt;button class=&quot;btn btn-primary w-100&quot; type=&quot;submit&quot;&gt;Send Message&lt;/button&gt;
                &lt;/form&gt;
              &lt;/div&gt;
            &lt;/div&gt;

I've tried using the disposable email service as well and it still doesn't work with my code.

Could anyone help me out with that?

答案1

得分: 0

问题在于表单组件的enctype特性。enctype属性指示在提交到服务器之前应如何对表单数据进行编码。在这种情况下,表单使用"text/plain"编码,这不适用于FormSubmit。

FormSubmit要求表单数据以"application/x-www-form-urlencoded"或"multipart/form-data"格式进行编码。这些配置允许数据以键-值对的方式发送,其中键与表单字段的名称相对应。

要解决这个问题,开发人员应该从表单标签中删除enctype属性。这样,表单将默认使用"application/x-www-form-urlencoded"编码,这与FormSubmit兼容。这个更改将使表单数据以字段名称和相应的值正确发送。

修改后的代码应该如下所示:

<div class="col-lg-6">
  <div class="contact-form">
    <form action="https://formsubmit.co/myemailwashere@gmail.com" method="POST">
      <input type="hidden" name="_next" value="https://mywebsite..app/thanks.html">
      <div class="form-group mb-4 pb-2">
        <label for="exampleFormControlInput1" class="form-label">Full Name</label>
        <input type="text" class="form-control shadow-none" name="name" id="contact_name">
      </div>
      <div class="form-group mb-4 pb-2">
        <label for="exampleFormControlInput1" class="form-label">Email address</label>
        <input type="email" class="form-control shadow-none" name="email" id="contact_email">
      </div>
      <div class="form-group mb-4 pb-2">
        <label for="exampleFormControlTextarea1" class="form-label">Write Message</label>
        <textarea name="message" class="form-control shadow-none" id="exampleFormControlTextarea1" placeholder="message" rows="3"></textarea>
      </div>
      <button class="btn btn-primary w-100" type="submit">Send Message</button>
    </form>
  </div>
</div>

在进行这个更改后,表单数据将以正确的格式发送,当用户提交表单时,收到的电子邮件应该包含预期的完整数据。

英文:

The issue with the structure lies in the enctype characteristic of the structure component. The enctype quality indicates how the structure information ought to be encoded prior to submitting it to the server. For this situation, the structure is utilizing "text/plain" encoding, which isn't reasonable for FormSubmit.

FormSubmit requires the structure information to be encoded in by the same token "application/x-www-structure urlencoded" or "multipart/structure information" design. These configurations permit information to be sent with key-esteem matches, where the keys relate to the names of the structure fields.

To fix the issue, the software engineer ought to eliminate the enctype property from the structure tag. Thusly, the structure will default to "application/x-www-structure urlencoded" encoding, which is viable with FormSubmit. This change will empower the structure information to be sent accurately with the field names and relating values.

The amended code ought to seem to be this:

&lt;div class=&quot;col-lg-6&quot;&gt;
  &lt;div class=&quot;contact-form&quot;&gt;
    &lt;form action=&quot;https://formsubmit.co/myemailwashere@gmail.com&quot; method=&quot;POST&quot;&gt;
      &lt;input type=&quot;hidden&quot; name=&quot;_next&quot; value=&quot;https://mywebsite..app/thanks.html&quot;&gt;
      &lt;div class=&quot;form-group mb-4 pb-2&quot;&gt;
        &lt;label for=&quot;exampleFormControlInput1&quot; class=&quot;form-label&quot;&gt;Full Name&lt;/label&gt;
        &lt;input type=&quot;text&quot; class=&quot;form-control shadow-none&quot; name=&quot;name&quot; id=&quot;contact_name&quot;&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group mb-4 pb-2&quot;&gt;
        &lt;label for=&quot;exampleFormControlInput1&quot; class=&quot;form-label&quot;&gt;Email address&lt;/label&gt;
        &lt;input type=&quot;email&quot; class=&quot;form-control shadow-none&quot; name=&quot;email&quot; id=&quot;contact_email&quot;&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group mb-4 pb-2&quot;&gt;
        &lt;label for=&quot;exampleFormControlTextarea1&quot; class=&quot;form-label&quot;&gt;Write Message&lt;/label&gt;
        &lt;textarea name=&quot;message&quot; class=&quot;form-control shadow-none&quot; id=&quot;exampleFormControlTextarea1&quot; placeholder=&quot;message&quot; rows=&quot;3&quot;&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;button class=&quot;btn btn-primary w-100&quot; type=&quot;submit&quot;&gt;Send Message&lt;/button&gt;
    &lt;/form&gt;
  &lt;/div&gt;
&lt;/div&gt;

Subsequent to rolling out this improvement, the structure information will be sent in the right configuration, and when the client presents the structure, the email got ought to contain the finished up data true to form.

huangapple
  • 本文由 发表于 2023年8月5日 13:31:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76840274.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定