我正在尝试使用AMP设置一个带有联系表单的页面:
该表单仅包含4个字段:
- 姓名
- 电子邮件:
- 我们如何提供帮助?
- 电话号码:
然后,我希望将这些信息发送到我的电子邮件地址 - 这是我在HTML中所拥有的。
<h4>How can we help?</h4>
<form class="p3 hide-inputs"
method="post"
action-xhr="/ampmail.php"
target="_top">
<div class="ampstart-input inline-block relative mb3">
<input type="text"
name="name"
placeholder="Name..."
required>
</div>
<div class="ampstart-input inline-block relative mb3">
<input type="email"
name="email"
placeholder="Email...">
</div>
<div class="ampstart-input inline-block relative mb3">
<input type="text-area"
name="enquiry"
placeholder="How can we help?">
</div>
<div class="ampstart-input inline-block relative mb3">
<input type="tel"
name="my_tel"
placeholder="Contact Number">
</div>
<input type="submit"
value="Contact Me"
class="ampstart-btn caps">
<div submit-success>
<template type="amp-mustache">
Success! Thanks {{name}}. Our design specialists will contact you shortly.
</template>
</div>
<div submit-error>
<template type="amp-mustache">
Error! Thanks {{name}} for trying the
<code>amp-form</code> demo with an error response.
</template>
</div>
</form>
然后在我的ampmail.php文件中,有以下内容:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['my_tel'];
$formcontent=" From: $name \n Phone: $my_tel";
$recipient = "admin@example.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
但是看起来这两者没有交流。