如何使我的联系表有效?
How to make my contact form work?
我是网页设计的初学者,我刚刚使用 html、css 和一点点 javascript 制作了我的第一个网站。我有一个小联系表,我想知道是否可以在不使用 PHP、bootstrap 等的情况下使其工作。
这是我的 html 代码:
<div class="form">
<p>some text goes here<br>
<br>some text here</p>
<form action="#" method="post">
<label for="form-name">Your name:</label> <input type="text" name="name" id="form-name" /><br>
<label for="form-city">Your email:</label> <input type="text" name="city" id="form-city" /><br>
<label for="form-story">Your message:</label><br />
<textarea name="story" rows="5" cols="60" maxlenght="300" id="story> </textarea><br>
<input type="submit" value="Send" />
</form>
</div>
另外,我想我在 "Your email:" 部分犯了一个错误,如果你也能帮助我,我将不胜感激。
那么,谁能告诉我需要什么代码才能让我的联系表在我的网站上线后向我发送电子邮件?
为此,您需要使用服务器端语言,例如 PHP 来处理表单。
HTML <form>
元素不会自动工作。它们就像一张纸。要将本文发送给您,您需要邮寄它,即通过服务器端脚本。这通常使用 PHP 完成。该表单通过 action
和 method
属性将用户输入的数据传递给 PHP 脚本:
<form action="page.php" method="post">
在这种情况下,信息将使用 POST
方法发送到 page.php
页面。通常使用的方法有两种:GET
和POST
。 GET
通过 URL 发送信息 (http://www.example.com/page.php?field1=someAnswer&field2=anotherAnswer), while POST
sends it through the server as $_SESSION
array. These individual values can be retrieved through $_SESSION['field1']
. For your contact form, take a look at PHP's mail
function here
我是网页设计的初学者,我刚刚使用 html、css 和一点点 javascript 制作了我的第一个网站。我有一个小联系表,我想知道是否可以在不使用 PHP、bootstrap 等的情况下使其工作。 这是我的 html 代码:
<div class="form">
<p>some text goes here<br>
<br>some text here</p>
<form action="#" method="post">
<label for="form-name">Your name:</label> <input type="text" name="name" id="form-name" /><br>
<label for="form-city">Your email:</label> <input type="text" name="city" id="form-city" /><br>
<label for="form-story">Your message:</label><br />
<textarea name="story" rows="5" cols="60" maxlenght="300" id="story> </textarea><br>
<input type="submit" value="Send" />
</form>
</div>
另外,我想我在 "Your email:" 部分犯了一个错误,如果你也能帮助我,我将不胜感激。 那么,谁能告诉我需要什么代码才能让我的联系表在我的网站上线后向我发送电子邮件?
为此,您需要使用服务器端语言,例如 PHP 来处理表单。
HTML <form>
元素不会自动工作。它们就像一张纸。要将本文发送给您,您需要邮寄它,即通过服务器端脚本。这通常使用 PHP 完成。该表单通过 action
和 method
属性将用户输入的数据传递给 PHP 脚本:
<form action="page.php" method="post">
在这种情况下,信息将使用 POST
方法发送到 page.php
页面。通常使用的方法有两种:GET
和POST
。 GET
通过 URL 发送信息 (http://www.example.com/page.php?field1=someAnswer&field2=anotherAnswer), while POST
sends it through the server as $_SESSION
array. These individual values can be retrieved through $_SESSION['field1']
. For your contact form, take a look at PHP's mail
function here