我已经基于Twitter Bootstrap 3构建了一个WordPress主题。x、 我在模式框中有一个邮件表单。当我单击submit按钮时,它返回404错误页。我也检查过了for reserved names 在里面$_POST
和$_REQUEST
变量。
原因是什么?
<?php get_header(); ?>
<script src=\'https://www.google.com/recaptcha/api.js\'></script>
<?php
$hasError = \'\';
$succMsg = \'\';
if(!empty($_SERVER[\'HTTP_X_FORWARDED_FOR\'])) {
$bsvr_ip_address = $_SERVER[\'HTTP_X_FORWARDED_FOR\'];
} else {
$bsvr_ip_address = $_SERVER[\'REMOTE_ADDR\'];
}
if(isset($_POST[\'submit\']) && !empty($_POST[\'submit\'])):
if(isset($_POST[\'g-recaptcha-response\']) && !empty($_POST[\'g-recaptcha-response\'])):
$secret = \'key\';
$verifyResponse = file_get_contents(\'https://www.google.com/recaptcha/api/siteverify?secret=\'.$secret.\'&response=\'.$_POST[\'g-recaptcha-response\']);
$responseData = json_decode($verifyResponse);
if (!empty($_POST[\'bsvr_name\'])) {
$bsvr_name = stripslashes(trim($_POST[\'bsvr_name\']));
} else {
$hasError = "Lütfen adınızı giriniz.";
}
if (!empty($_POST[\'bsvr_email\'])) {
$bsvr_email = stripslashes(trim($_POST[\'bsvr_email\']));
} else if ( ! eregi( "^[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}$", trim($_POST[\'bsvr_email\'] ) ) ) {
$hasError = \'Geçersiz e-posta adresi girdiniz.\';
} else {
$hasError = "Lütfen e-posta adresinizi giriniz.";
}
$bsvr_egitim = $_POST[\'bsvr_egitim\'];
if($responseData->success):
$to = \'tomail\';
$subject = \'Title\';
$htmlContent = "
<h1>Content</h1>
<p><b>Name: </b>".$bsvr_name."</p>
<p><b>E-Mail: </b>".$bsvr_email."</p>
<p><b>Title: </b>".$bsvr_egitim."</p><br/><br/>
<p><b>IP: </b>".$bsvr_ip_address."</p>
";
$headers = "MIME-Version: 1.0" . "\\r\\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\\r\\n";
$headers .= \'From:\'.$bsvr_name.\' <\'.$bsvr_email.\'>\' . "\\r\\n";
@mail($to,$subject,$htmlContent,$headers);
$succMsg = "Ok..";
$bsvr_name = \'\';
$bsvr_email = \'\';
$bsvr_egitim = \'\';
else :
$hasError = "Bir hata oluştu, lütfen tekrar deneyiniz.";
endif;
else :
$hasError = "Bir hata oluştu, lütfen tekrar deneyiniz.";
endif;
else :
$hasError = \'\';
$succMsg = \'\';
$bsvr_name = \'\';
$bsvr_email = \'\';
$bsvr_egitim = \'\';
endif;
?>
<!-- Modal -->
<div class="modal fade" id="basvuru" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">EĞİTİME BAŞVUR</h4>
</div>
<div class="modal-body">
<form class="contactForm" id="egitimform" name="egitimform" method="post" action="<?php the_permalink(); ?>" enctype="multipart/form-data">
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="bsvr_name" id="bsvr_name" placeholder="Name">
</div>
</div>
<div class="form-group">
<label for="bsvr_email" class="col-sm-3 control-label">E-Mail</label>
<div class="col-sm-9">
<input type="bsvr_email" class="form-control" name="bsvr_email" id="bsvr_email" placeholder="E-Mail">
</div>
</div>
<div class="form-group">
<div class="col-sm-9 col-sm-offset-3">
<div class="g-recaptcha" data-sitekey="key"></div>
</div>
</div>
<input type="hidden" name="bsvr_egitim" value="<?php the_title(); ?>">
</form>
</div>
<div class="modal-footer">
<input type="submit" name="submit" class="button" id="egitimsubmit" value="GÖNDER">
</div>
</div>
</div>
</div>
<script>
$(\'#egitimsubmit\').on(\'click\', function(e){
// We don\'t want this to act as a link so cancel the link action
e.preventDefault();
// Find form and submit it
$(\'#egitimform\').submit();
});
</script>