Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> PHP mailer., PHP mailer nie podaje danych z formularza w mailu.
kurde
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 8.09.2013

Ostrzeżenie: (0%)
-----


Witam. Mam problem z formularzem kontaktowym na http://www.biorel.pl

Nie przesyła do mnie na maila pola twój adres email. Przez co nie wiem komu na jaki adres trzeba odpisać na pytania, które coraz częściej wysyłają.


Co mam przesłać jakieś kody źródłowe czy coś. Proszę o poradę.

Ten post edytował kurde 1.03.2016, 20:57:31
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kurde
post
Post #2





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 8.09.2013

Ostrzeżenie: (0%)
-----


Kod Formularza:

Kod
<p>
Masz pytanie odnośnie naszych usług, wypełnij formularz, postaramy się niezwłocznie odpisać.
</p>


<!-- comment-form -->
               <div class="row">
                 <form method="post" action="sendEmail.php">
                   <div>
                     <div id="main">
                       <div class="span8">
                         <div class="comment1">
                           <p><input type="text" placeholder="twoje imie" name="name" id="name" class="commentfield" />
                           </p>
                         </div>
                           <div class="comment2">
                             <p> <input type="text" placeholder="twój adres e-mail" name="email" id="email" class="commentfield" />
                             </p>
                           </div>
                         <div class="comment3">
                           <p> <input type="text" placeholder="Temat" name="subject" id="subject" class="commentfield" />
                           </p>
                         </div>
                       </div>
                       <div class="span8 textarea">
                         <p><textarea name="comments" placeholder="Twoja wiadomość" id="comments" rows="12" cols="5" class="textarea"></textarea>
                         </p>
                         <div class="buttoncontact">
                           <p><input type="submit"  name="submit"  class="buttoncontact" id="submit" value="send message"/>
                           </p>
                         </div>
                       </div>
                       <ul class="span8" id="response"></ul>
                     </div>
                   </div>
                 </form>
               </div>
            
             <!-- comment-form-end -->


</div><!--leftabout end-->




Kod Obsługi:

Kod
<?php
    
    $name = trim($_POST['name']);
    $email = $_POST['email'];
        $subject = $_POST['subject'];
    $comments = $_POST['comments'];


        $site_owners_email = 'karol.manitus21@gmail.com'; // Replace this with your own hosting email address
    $site_owners_name = 'karol'; // replace with your name
    
    if (strlen($name) < 2) {
        $error['name'] = "Please enter your name";    
    }
    
    if (!preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
        $error['email'] = "Please enter a valid email address";    
    }
    
    if (strlen($comments) < 3) {
        $error['comments'] = "Please leave a comment.";
    }

        if (strlen($subject) < 2) {
        $error['subject'] = "Please enter subject.";
    }
    
    
    if (!$error) {
        
        require_once('phpMailer/PHPMailerAutoload.php');
        $mail = new PHPMailer();
        
        $mail->From = $email;
        $mail->FromName = $name;
        $mail->Subject = "$subject";
        $mail->AddAddress($site_owners_email, $site_owners_name);
        $mail->AddAddress('', '');
        $mail->IsHTML(true);  


$mail->Body = $comments;
$mail->email = $email;

        $mail->IsSMTP();
        $mail->Host = "smtp.gmail.com";
         $mail->Port = 587;
         $mail->SMTPSecure = "tls";
        
        $mail->SMTPAuth = true; // turn on SMTP authentication
        $mail->Username = "karol.manitus21@gmail.com"; // SMTP username
         $mail->Password = "hasła nie podam"; // SMTP password
        
        
$mail->SMTPDebug  = 0;
echo "<li class='success'> Dziękujemy, " . $name . ". Odpiszemy niezwłocznie jak tylko to będzie możliwe.</li>";
        
    } # end if no error
    else {

        $response = (isset($error['name'])) ? "<li class='error'>" . $error['name'] . "</li> \n" : null;
        $response .= (isset($error['email'])) ? "<li class='error'>" . $error['email'] . "</li> \n" : null;
                $response .= (isset($error['subject'])) ? "<li class='error'>" . $error['subject'] . "</li> \n" : null;
        $response .= (isset($error['comments'])) ? "<li class='error'>" . $error['comments'] . "</li>" : null;
        
        echo $response;
    } # end if there was an error sending


    if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}


?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.10.2025 - 16:21