我有一个表单脚本,在提交后发送电子邮件。 javascript在提交后删除了表单。
但是当我提交表单时,它会显示空的.php文件。
继承我的index.html代码:
<!--Here is container with email subscription-->
<div class="container-fluid yellow-container bg-mail">
<div class="row-fluid">
<div class="span12">
<h2>Laat hier je email adres achter, zodat wij weten dat je van de partij bent</h2>
<p>Deze uitnodiging geldt voor jou en een relatie!</p>
<form action="save.php" id="subscribe-form" method="post" name="subscribe-form">
<input type="email" name="email" placeholder="Hier je emailadres" id="email" class="email required">
<button class="btn btn-inverse" id="submit" type="submit" value="Subscribe">Count me in!</button>
</form>
</div>
</div>
</div>
&#13;
save.php代码:
<?php
if (isset($_POST['email'])) {
//Email information
$admin_email = "marco@daretodesign.nl";
$email = $_POST['email'];
//send email
mail($admin_email, "Inschrijving via Dukdalf", $email . " " . "heeft zich ingeschreven via de website", "Van:" . $email);
}
?>
&#13;
javascript代码:
//Subscribe Form
if($('#subscribe-form').length && jQuery()) {
$('form#subscribe-form').submit(function() {
$('form#subscribe-form .error').remove();
var hasError = false;
$('.required').each(function() {
if(jQuery.trim($(this).val()) === '') {
var labelText = $(this).prev('label').text();
$(this).parent().append('<div class="error">Vul a.u.b. uw email in.'+labelText+'</div>');
$(this).addClass('inputError');
hasError = true;
} else if($(this).hasClass('email')) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test(jQuery.trim($(this).val()))) {
var labelText = $(this).prev('label').text();
$(this).parent().append('<div class="error">Vul a.u.b. een geldig email in.'+labelText+'</div>');
$(this).addClass('inputError');
hasError = true;
}
}
});
if(!hasError) {
$('form#subscribe-form input.submit').fadeOut('normal', function() {
$(this).parent().append('');
});
var formInput = $(this).serialize();
$.post($(this).attr('action'),formInput, function(data){
$('form#subscribe-form').slideUp("fast", function() {
$(this).before('<div class="error">Bedankt voor het inschrijven!</div>');
});
});
}
return false;
});
&#13;
提前感谢您的帮助:)
答案 0 :(得分:0)
header('Location: http://www.example.com/');
exit;
此致 马塞洛