我尝试过使用action =" mail.site.com",info @ site.com,页面只刷新而不发送查询表单。我想我需要一个PHP或Ajax页面将电子邮件发送到服务器并为用户提供响应。我尝试了一些我不擅长PHP的东西。如果有人有任何见解,将不胜感激。谢谢。
<section style="background: url(_images/pattern.html)" class="reservation parallax-repeat dark">
<div class=reservation__inner>
<div class=container>
<div class=row>
<div class="col-sm-8 col-lg-6 col-sm-offset-2 col-lg-offset-3 text-center">
<header class=section-header>
<h2>Servicio de reservas</h2>
<div class=divider></div>
<p>
Para que el mantenimiento de su vehículo sea rápido y sin complicaciones, le recomendamos encarecidamente que realice una reserva en línea. Es completamente gratis y no te llevará mucho tiempo.</header>
</div>
</div>
<div class=reservation-form>
<form id=reservForm action=# method=POST data-toggle=validator>
<div class=reservation-form__center-wrapper>
<div class="form-group item-1">
<label for=resName class=label-control>Tu Nombre</label>
<div class="input-wrap input-wrap--icon-left"><i class="input-icon pe-7s-user"></i>
<input id=resName type=text name=field_name placeholder="David Kraemer" required class=form-control>
</div>
</div>
<div class="form-group item-2">
<label for=resNumber class=label-control>Su Teléfono</label>
<div class="input-wrap input-wrap--icon-left"><i class="input-icon pe-7s-phone"></i>
<input id=resNumber type=tel name=field_tel placeholder="+1 (812) 281 55 23" required class=form-control>
</div>
</div>
<div class="form-group item-3">
<label for=resDate class=label-control>Fecha</label>
<div class="input-wrap input-wrap--icon-left"><i class="input-icon pe-7s-date"></i>
<input id=resDate type=text name=field_date placeholder=09/18/2016 required class="form-control pick-date">
</div>
</div>
<div class="form-group item-4">
<label for=resTime class=label-control>Hora</label>
<div class=input-wrap><i class="input-icon fa fa-caret-down"></i>
<input id=resTime type=text name=field_time placeholder=16:30 required class="form-control time-pick">
</div>
</div>
</div>
<button type=submit class="btn btn-regular btn-accent"><span class=btn-text>
Hacer una reserva</span><span class=btn-over></span></button>
</form>
</div>
</div>
</div>
</section>
&#13;
答案 0 :(得分:-1)
我可以看到你构建了html表单,你缺少的部分将添加表单数据将被处理的url。
<form id=reservForm action="sendemail.php" method=POST data-toggle=validator>
完成后,您需要创建一个sendemail.php文件,并访问用户键入php代码的用户数据:
<?php
$name = $_POST['field_name'];
$tel = $_POST['field_tel'];
$date = $_POST['field_date'];
$time = $_POST['field_time'];
?>
获取数据后,您需要验证每个数据以查看类型格式是否符合您的要求。请尝试阅读form validation
最后但并非最不重要的是,如果一切顺利,您可以使用下面的示例代码继续发送电子邮件:
<?php
$to = "abc@domain.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
?>
您可以阅读有关发送电子邮件here的更多信息。