HTML表单:如何使其工作? [英] HTML Form: How do I make it work?

查看:90
本文介绍了HTML表单:如何使其工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,朋友们!我是html中的总菜鸟,如何让我的表单工作?以下是我正在尝试制作的表格的链接→表格



如何编写将表格中的数据发送到我的电子邮件的脚本?非常感谢!



这是我到目前为止唯一拥有的东西:



< form>

联系方式:



< input type =textplaceholder =Name>

< input type =textplaceholder =姓氏>

< input type =emailplaceholder =E-mail>

< ;输入类型=文字占位符=电话号码>



发货:



< ; input type =textplaceholder =Address>

< input type =textplaceholder =City>

< input type = text占位符=地区>

< input type =text占位符=国家/地区>

< input type =text占位符=邮政编码>



< input type =submitvalue =立即订购>

< / form>

Hello, friends! I am a total noob in html, how do I make my form work? Here is the link to the form I am trying to make → FORM

How do I write the script which sends the data from the form to my e-mail? Thanks a lot!

This is the only thing I have so far:

<form>
Contact details:

<input type="text" placeholder="Name">
<input type="text" placeholder="Last name">
<input type="email" placeholder="E-mail">
<input type="text" placeholder="Phone number">

Shipment:

<input type="text" placeholder="Address">
<input type="text" placeholder="City">
<input type="text" placeholder="Region">
<input type="text" placeholder="Country">
<input type="text" placeholder="ZIP code">

<input type="submit" value="Order now">
</form>

推荐答案

请参阅我的评论问题。如果你需要向服务器端提交一些HTTP请求,我可以看到以下缺点:



1)每个输入元素应该具有<$ c $的属性c> name ,此属性的值在表单中应该是唯一的。 2)表单元素应具有属性方法,通常为 method =post,3)表单元素应该具有属性 action 。它的值应该是处理HTTP请求的PHP脚本。



请参阅:https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms [ ^ ]。



另请参阅(您无需执行所有操作): https: //developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects [ ^ ]。



坦率地说,如果你还需要做其他事情,不发送HTTP请求,您实际上不需要使用该表单。但是要使用表单和所有请求数据,您需要在PHP中处理它,这非常简单,但却是完全不同的故事。请参阅: http://php.net/manual/en/tutorial.forms.php [< a href =http://php.net/manual/en/tutorial.forms.phptarget =_ blanktitle =New Window> ^ ]。



-SA
Please see my comment to the question. If you need to submit some HTTP request to the server side, I can see the following missing points:

1) Each input element should have the attribute name, the values of this attributes should be unique in the form. 2) the form element should have the attribute method, typically, method="post", 3) the form element should have the attribute action. Its value should be your PHP script which handles the HTTP request.

Please see: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms[^].

See also (you don't have to do it all): https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects[^].

Frankly, if you need to do anything else, not sending HTTP request, you don't really need to use the form. But to use the form and all the request data, you need to handle it all in PHP, which quite easy, but is the whole different story. Please see: http://php.net/manual/en/tutorial.forms.php[^].

—SA


这篇关于HTML表单:如何使其工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆