• Hello..

    I’ve builded a WordPress theme based on bootstrap 3.x

    I’ve mail form in modal box. When I click submit button, it returns 404 error page.

    What the reason can be?

    Thanks.

    <?php get_header(); ?>
    <script src='https://www.google.com/recaptcha/api.js'></script>
    <?php
    $hasError = '';
    $succMsg = '';
    
    if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip_address = $_SERVER['REMOTE_ADDR'];
    }
    
    if(isset($_POST['submit']) && !empty($_POST['submit'])):
    
    	if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])):
    
    		$secret = '';
    		$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['adsoyad'])) {
    			$name = stripslashes(trim($_POST['adsoyad']));
    		} else {
    			$hasError = "Lütfen ad?n?z? giriniz.";
    		}
    
    		if (!empty($_POST['email'])) {
    			$email = stripslashes(trim($_POST['email']));
    		} else if ( ! eregi( "^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email'] ) ) ) {
    			$hasError = 'Ge?ersiz e-posta adresi girdiniz.';
    		} else {
    			$hasError = "Lütfen e-posta adresinizi giriniz.";
    		}
    
    		$egitim = $_POST['egitim'];
    
    		if($responseData->success):
    
    			$to = '';
    			$subject = '';
    			$htmlContent = "
    				<h1>Form ??eri?i</h1>
    				<p><b>Ad Soyad: </b>".$name."</p>
    				<p><b>E-posta Adresi: </b>".$email."</p>
    				<p><b>E?itim: </b>".$egitim."</p><br/><br/>
    				<p><b>IP Adresi: </b>".$ip_address."</p>
    			";
    			$headers = "MIME-Version: 1.0" . "\r\n";
    			$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    			$headers .= 'From:'.$name.' <'.$email.'>' . "\r\n";
    
    			@mail($to,$subject,$htmlContent,$headers);
    
    			$succMsg = "?leti?ime ge?ti?iniz i?in te?ekkür ederiz. ?lgili departman en k?sa sürede sizinle irtibata ge?ecektir.";
    			$name = '';
    			$sname = '';
    			$email = '';
    			$message = '';
    
    		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 = '';
    	$name = '';
    	$sname = '';
    	$email = '';
    	$message = '';	
    
    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">&times;</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(); ?>">
    					<div class="form-group">
    						<label for="adsoyad" class="col-sm-3 control-label">Ad Soyad</label>
    						<div class="col-sm-9">
    							<input type="text" class="form-control" name="adsoyad" id="adsoyad" placeholder="Ad Soyad">
    						</div>
    					</div>
    					<div class="form-group">
    						<label for="email" class="col-sm-3 control-label">E-Posta Adresi</label>
    						<div class="col-sm-9">
    							<input type="email" class="form-control" name="email" id="email" placeholder="E-Posta Adresiniz">
    						</div>
    					</div>
    					<div class="form-group">
    						<div class="col-sm-9 col-sm-offset-3">
    							<div class="g-recaptcha" data-sitekey="6LdyxB4TAAAAAAK6gf4m5OnUVcKpL8PMJCg5EtwG"></div>
    						</div>
    					</div>
    					<input type="hidden" name="egitim" value="<?php the_title(); ?>">
    					<input type="submit" name="submit" class="button" id="egitimsubmit" value="G?NDER">
    				</form>
    			</div>
    		</div>
    	</div>
    </div>
  • The topic ‘Mail Form in a modal box’ is closed to new replies.