我要做一个“登陆页面”拆分并使用2个不同的联系表单。 这是链接http://aquila-test.nowcommu.myhostpoint.ch/
当我尝试发送测试邮件时,我无法重新发送它并重新加载页面。这是.php代码`
$to_Email = "antonio.casarano@now-ad.ch"; // Write your email here
// Use PHP To Detect An Ajax Request
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
// Exit script for the JSON data
$output = json_encode(
array(
'type'=> 'error',
'text' => 'Request must come from Ajax'
));
die($output);
}
// Checking if the $_POST vars well provided, Exit if there is one missing
if(!isset($_POST["userName"]) || !isset($_POST["userEmail"]) || !isset($_POST["userSubject"]) || !isset($_POST["userMessage"])) {
$output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> Input fields are empty!'));
die($output);
}
// PHP validation for the fields required
if(empty($_POST["userName"])) {
$output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> We are sorry but your name is too short or not specified.'));
die($output);
}
if(!filter_var($_POST["userEmail"], FILTER_VALIDATE_EMAIL)) {
$output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> Please enter a valid email address.'));
die($output);
}
// To avoid the spammy bots, you can change the value of the minimum characters required. Here it's <20
if(strlen($_POST["userMessage"])<20) {
$output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> Too short message! Take your time and write a few words.'));
die($output);
}
// Proceed with PHP email
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type:text/html;charset=UTF-8' . "\r\n";
$headers .= 'From: My website' . "\r\n";
$headers .= 'Reply-To: '.$_POST["userEmail"]."\r\n";
'X-Mailer: PHP/' . phpversion();
// Body of the Email received in your Mailbox
$emailcontent = 'Hey! You have received a new message from the visitor <strong>'.$_POST["userName"].'</strong><br/><br/>'. "\r\n" .
'His message: <br/> <em>'.$_POST["userMessage"].'</em><br/><br/>'. "\r\n" .
'<strong>Feel free to contact '.$_POST["userName"].' via email at : '.$_POST["userEmail"].'</strong>' . "\r\n" ;
$Mailsending = @mail($to_Email, $_POST["userSubject"], $emailcontent, $headers);
if(!$Mailsending) {
//If mail couldn't be sent output error. Check your PHP email configuration (if it ever happens)
$output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> Oops! Looks like something went wrong, please check your PHP mail configuration.'));
die($output);
} else {
$output = json_encode(array('type'=>'message', 'text' => '<i class="icon ion-checkmark-round"></i> Hello '.$_POST["userName"].', Your message has been sent, we will get back to you asap !'));
die($output);
}
HTML:
<!-- OPEN - LEFT PART -->
<div class="ms-left animated-middle">
<!-- OPEN - 1st Left Part -->
<div class="ms-section" id="left1">
<!-- Overlay -->
<div class="overlay_none"></div>
<!-- OPEN - Content -->
<div class="item-title text-center">
<!-- Your logo -->
<div id="sinistra">
<p id="testo_left1" style="font-size: 2.0em;"><b>Schreiben Sie Erfolgsgeschichte.</b></p>
<p id="testo_left2" style="font-size: 1.075em;" line>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.<br>Ut enim ad minim veniam.</p>
<img id="prima" src="img/icon_arbeiten_small.png" alt="" class="brand-logo" width="256" height="222" />
<!-- Contact form -->
<p id="testo_left2" style="font-size: 1.5em;"><font size="4.5em;" id="headline_2"><b>Kanzlei. Büro. Praxis.<br><br><font style="font-size: 1.3em;">061 317 67 87</font></b></font></p>
<form id="contact-form" name="contact-form" method="POST" data-name="Contact Form">
<div class="row">
<!-- Full name -->
<div class="col-xs-12 col-sm-6 col-lg-6">
<div class="form-group">
<input type="text" id="name" class="form form-control" placeholder="Name und Vorname" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Name und Vorname'" name="name" data-name="Name" required>
</div>
</div>
<!-- E-mail -->
<div class="col-xs-12 col-sm-6 col-lg-6">
<div class="form-group">
<input type="email" id="email" class="form form-control" placeholder="E-Mail" onfocus="this.placeholder = ''" onblur="this.placeholder = 'E-Mail'" name="email-address" data-name="Email Address" required>
</div>
</div>
<!-- Subject -->
<div class="col-xs-12 col-sm-12 col-lg-12">
<div class="form-group">
<input type="text" id="subject" class="form form-control" placeholder="Betreff" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Betreff'" name="subject" data-name="Subject">
</div>
</div>
<!-- Message -->
<div class="col-xs-12 col-sm-12 col-lg-12 no-padding">
<div class="form-group">
<textarea id="text-area" class="form textarea form-control" placeholder="Ihre Nachricht..." onfocus="this.placeholder = ''" onblur="this.placeholder = 'Ihre Nachricht...'" name="message" data-name="Text Area" required></textarea>
</div>
</div>
</div>
<!-- Button submit -->
<button type="submit" id="valid-form" class="btn btn-color">Senden</button>
</form>
<!-- /. Contact form -->
</div> <!-- CLOSE - Content -->
</div>
</div> <!-- CLOSE - 1st Left Part -->
</div> <!-- CLOSE - LEFT PART -->
<!-- OPEN - RIGHT PART -->
<div class="ms-right animated-middle" id="right-part">
<!-- OPEN - 1st Right Part -->
<div class="ms-section" id="right1">
<div><img src="img/logo-aquila_weiss.png" alt="" width: "200" align="left" class="main_logo" /></div>
<!-- Overlay -->
<div class="overlay_none"></div>
<!-- OPEN - Content -->
<div class="item-title text-center">
<!-- OPEN - Countdown part -->
<div id="sinistra">
<p id="testo_left1" style="font-size: 2.0em;"><b>Leben Sie extravagant.</b></p>
<p id="testo_left2" style="font-size: 1.075em;" line>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.<br>Ut enim ad minim veniam.</p>
<img id="prima" src="img/icon_wohnen_small.png" alt="" class="brand-logo" width="256" height="222" />
<!-- Contact form -->
<p id="testo_left2" style="font-size: 1.5em;"><font size="4.5em;" id="headline_2"><b>Schöner Wohnen.<br><br><font style="font-size: 1.3em;">061 317 67 87</font></b></font></p>
<form id="contact-form" name="contact-form" method="POST" data-name="Contact Form">
<div class="row">
<!-- Full name -->
<div class="col-xs-12 col-sm-6 col-lg-6">
<div class="form-group">
<input type="text" id="name" class="form form-control" placeholder="Name und Vorname" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Name und Vorname'" name="name" data-name="Name" required>
</div>
</div>
<!-- E-mail -->
<div class="col-xs-12 col-sm-6 col-lg-6">
<div class="form-group">
<input type="email" id="email" class="form form-control" placeholder="E-Mail" onfocus="this.placeholder = ''" onblur="this.placeholder = 'E-Mail'" name="email-address" data-name="Email Address" required>
</div>
</div>
<!-- Subject -->
<div class="col-xs-12 col-sm-12 col-lg-12">
<div class="form-group">
<input type="text" id="subject" class="form form-control" placeholder="Betreff" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Betreff'" name="subject" data-name="Subject">
</div>
</div>
<!-- Message -->
<div class="col-xs-12 col-sm-12 col-lg-12 no-padding">
<div class="form-group">
<textarea id="text-area" class="form textarea form-control" placeholder="Ihre Nachricht..." onfocus="this.placeholder = ''" onblur="this.placeholder = 'Ihre Nachricht...'" name="message" data-name="Text Area" required></textarea>
</div>
</div>
</div>
<!-- Button submit -->
<button type="submit" id="valid-form" class="btn btn-color">Senden</button>
</form>
<!-- /. Contact form -->
</div> <!-- CLOSE - Content -->
</div>
</div> <!-- CLOSE - 1st Left Part -->
</div> <!-- CLOSE - Content -->