无法让表单正常工作。
是否有任何易于创建的html表单只会在提交时发送电子邮件?
任何人都可以提供一些代码示例吗?
我试图让它工作但它始终没有回复电子邮件。在表单中,我试图获取日期,时间,可输入的位置,号码乘客和汽车,汽车类型,姓名电子邮件和消息。
<form class="booking-form">
<div class="row">
<!-- <div class="col-xs-6 col-sm-2">
<fieldset class="car-type">
<input type="checkbox" name="car-type" id="econo" />
<label for="econo"><i class="icon-car-econo"></i>Econo</label>
</fieldset>
</div> -->
<div class="col-xs-6 col-sm-2">
<fieldset class="car-type">
<input type="checkbox" name="car-tclass="icon-car-LUXURY SEDANype" id="LUXURY SEDAN" />
<label for="LUXURY SEDAN"><i class="icon-car-classic"> </i>LUXURY SEDAN</label>
</fieldset>
</div>
<div class="col-xs-6 col-sm-2">
<fieldset class="car-type">
<input type="checkbox" name="car-type" id="EUROPEAN SEDAN" />
<label for="EUROPEAN SEDAN"><i class="icon-car-wagon"></i>EUROPEAN SEDAN</label>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<fieldset>
<input type="text" name="name" placeholder="Name" />
</fieldset>
<fieldset>
<input type="email" name="email" placeholder="Email" />
</fieldset>
</div>
<div class="col-sm-3">
<fieldset>
<input type="text" name="from1" placeholder="From" />
</fieldset>
<fieldset>
<input type="text" name="to1" placeholder="To" />
</fieldset>
</div>
<div class="col-sm-3">
<fieldset>
<input type="text" name="date" placeholder="Date1" class="datepicker" />
</fieldset>
<fieldset>
<input type="text" name="time" placeholder="Time" class="timepicker" />
</fieldset>
</div>
<div class="col-sm-3">
<fieldset>
<select name="cars">
<option>Cars</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</fieldset>
<fieldset>
<select name="passengers">
<option>Passengers</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<fieldset>
<textarea name="message2" placeholder="Message"></textarea>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-center">
<button class="btn btn-primary">Book Now</button>
</div>
</div>
</form>
答案 0 :(得分:0)
你需要后端语言
<!-- action->specify the destiny of data from form | method->indicate shipping method -->
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<input type="text" name="someText" placeholder="someText">
<input type="submit" name="sendText" value="sendText">
</form>
使用php,您可以发送数据表格
<?php
$errorMessage = ''; // case the user not complete all fields of the form
$to = 'myemail@company.com'; // destiny of message
if( isset($_POST['sendText']) ){ // comprobate the action of the input type submit
$someText = $_POST['someText']; // get the value of input type text
if( !empty($someText) ){ // comprobate if the variable is not empty
$someText = stripslashes(trim(filter_var($someText , FILTER_SANITIZE_STRING))); // this sanitize the text for avoid the code injection
mail($to,$someText); // this method only can send message when the web is working on server
}else{ // show an error message if text is empty
$errorMessage.="Please complete all fields <br>";
}
}
?>