我有一张表格并且表单正常工作:我收到了电子邮件中的所有详细信息。但是,当我点击提交时,它会重定向到一个空白页面,其中包含以下文字:“请求已成功提交。我们会尽快与您联系。”。
我想要做的是显示一个绿色方框,表示表单已成功提交,与大多数网站一样,并且不是重定向...
我正在使用Bootstrap:)
Mailer.php代码:
<?php
$tipoIn = $_POST['tipoIn'];
$Tipologia_input = $_POST['Tipologia_input'];
$sender_name = $_POST['Nome'];
$sender_email = $_POST['email'];
$phone = $_POST['Telefone'];
$slider_value = $_POST['slider_value'];
$mail_body = $_POST['message'];
$body = $sender_name." sent a new message for you<br><br> Name: ".$sender_name."<br>Email: ".$sender_email."<br>Phone: ".$phone."<br>Tipo: ".$tipoIn."<br>Tipologia: ".$Tipologia_input."<br>Slider Value: ".$slider_value."<br>Message: ".$mail_body;
sendMail($sender_name , $sender_email, $body);
function sendMail($sender, $sender_mail, $body) {
$to = 'geral@porta10.com'; // Set Receiver Email Here
$myemail = 'geral@porta10.comm'; // Set Sender Email Here
$subject = "New EasyLoan Client"; // Set Subject Here
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Lead <geral@porta10.com>\r\n"; // Set Header Here
$message = $body;
$sentmail = mail($to,$subject,$message,$headers);
if($sentmail) { echo "Request submitted successfully. We will contact with you very soon."; }
else { echo "Mail not sent"; }
}
?>
表格代码:
<div class="form-container">
<div class="form-mockup">
<h2>Que imóvel procura ?</h2>
<!-- <h4>Easy to apply for a loan with us,Once you have complete this form. </h4>-->
<form action="mailer.php" method="post">
<div class="form-group">
<select class="form-control" id="tipo" name="tipoIn">
<option value="Tipo" disabled selected>Tipo de imóvel</option>
<option value="Moradia">Moradia</option>
<option value="Apartamento">Apartamento</option>
</select>
</div>
<div class="form-group">
<select class="form-control" id="tipologia" name="Tipologia_input">
<option value="Tipologia" disabled selected>Tipologia</option>
<option value="T1">T1</option>
<option value="T2">T2</option>
<option value="T3">T3</option>
<option value="T4">T4</option>
<option value="T5">T5</option>
</select>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Nome Completo" name="Nome">
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="E-mail" name="email">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Telefone" name="Telefone">
</div>
<div class="form-group">
<textarea class="form-control" rows="3" id="comentario" placeholder="Diga-nos como imagina a sua casa..." name="message"></textarea>
</div>
<div class="form-group">
<div class="button-slider">
<div class="btn-group btn_group">
<div class="btn btn-default btn_amount">Valor </div>
<div class="btn btn-default btn_slider">
<input id="bootstrap-slider" type="text" data-slider-min="1" data-slider-max="50000" data-slider-step="1" data-slider-value="25000" name="slider_value" />
<div class="valueLabel"><span class="text_span">Valor </span> <span id="sliderValue">25000</span>€</div>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-default quote_btn">Enviar</button>
</form>
</div>
</div>
答案 0 :(得分:1)
你可以做各种事情,这取决于框架或cms或代码的逻辑。有很多方法可以完成这项任务(显示在(相同/现有)页面上而不是重定向到(空白/污损))但仍然取决于它。
我目前可以想象的两种主要方式是: