2016-03-21 21 views
0

Bootstrap ile biçimlendirilmiş bir form oluşturdum ve formun nasıl işlevsel hale getirileceğine ilişkin bir PHP öğreticisini takip ettim (bilgi belirli bir e-postaya gönderilecek bir e-posta ile doldurulduğunda) ancak iş.PHP - Form Gönderme Çalışmıyor

Stackoverflow'ta birçok iş parçacığı okudum ancak bir çözüm bulamadı.

php.ini dosyasını yapılandırdım (doğru düşünüyorum) ve hala mail() işlevi çalışmıyor.

Kodum aşağıda. PHP'de mutlak bir başlangıç ​​yapıyorum ve yardımlarınız için gerçekten minnettarım! evet o zaman e-posta işlevselliği işe değilse

<?php 

        function has_header_injection($str) { 
         return preg_match("/[\r\n]/", $str); 
        } 

        if (isset($_POST['contact_submit'])){ 

         $name = trim($_POST['name']); 
         $email = trim($_POST['email']); 
         $msg = $_POST['message']; 

         if (has_header_injection($name)||($email)) { 
          die; 
         } 

        if (!$name || !$email || !$message) { 
         echo '<h2 class="success">All fields are required</h2> <a href="contact.php" class="btn btn-custom btn-sm">Try again</a>'; 
        }  

        $to = "[email protected]"; (this has my true email) 
        $subject = "$name sent you a message via example's contact form"; 
        $message = "Name: $name\r\n"; 
        $message .= "Email: $email\r\n"; 
        $message .= "Message:\r\n$msg"; 

        $headers = "MIME-Version: 1.0\r\n"; 
        $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; 
        $headers .= "From: $name <$email>\r\n";  
        $headers .= "X-Priority: 1\r\n";  
        $headers .= "X-MSMail-Priority: High\r\n\r\n"; 

        mail($to, $subject, $message, $headers); 



       ?> 

       <h2 class="success"> Thank you! Your project request is submitted. We will get back to you within 24 hours.</h2> 
       <p><a href="index.php" class="btn btn-custom btn-sm">&laquo; Go to home page</a></p> 

       <?php } else { ?> 



       <form action="" class="contact-form" id="contact-form" method="post" role="form"> 
        <div class="form-group"> 
         <label class="sr-only" for="name">Name</label> 
         <input type="text" class="form-control" id="name" name="name" required="" placeholder="Name"> 
        </div> 
        <div class="form-group"> 
         <label class="sr-only" for="email">Email</label> 
         <input type="email" class="form-control" id="email" name="email" required="" placeholder="Email"> 
        </div> 
        <div class="form-group"> 
         <textarea class="form-control" id="message" name="message" placeholder="Enter a brief description of your project" required=""></textarea> 
        </div> 
        <button type="submit" class="btn btn-custom" name="contact_submit">Send</button> 
       </form> 

       <?php } ?> 
+0

Çift kez kontrol ettim ancak sorunum hala devam ediyor –

cevap

2

localhostla üzerinde çalışıyor musunuz, sunucuda kodunuzu koydu.

+0

Ben localhost'ta değilim. Kod bir web sitesinde ve canlı. –