Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z formularzem kontaktowym.
zelka20
post 17.03.2014, 21:39:16
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 31.07.2011

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


Witam, mam problem z formularzem kontaktowym, po wgraniu na serwer i "wysłaniu wiadomości" na e-mail nie dochodzi.

  1. <form method="POST" action="skrypt.php" id="contact-form">
  2. <div class="success">Twoja wiadomość została wysłana!</div>
  3. <div>
  4. <label class="name">
  5. <input name="name" type="text" value="Imię i nazwisko:">
  6. <br>
  7. <span class="error">*Niewłaściwe imie i nazwisko.</span> <span class="empty">*To pole jest wymagane.</span> </label>
  8. </div>
  9. <div>
  10. <label class="email">
  11. <input name="email" type="email" value="e-mail:">
  12. <br>
  13. <span class="error">*Niewłaściwy e-mail.</span> <span class="empty">*To pole jest wymagane.</span> </label>
  14. </div>
  15. <div>
  16. <label class="message">
  17. <textarea name="message" >Wiadomość:</textarea>
  18. <br>
  19. <span class="error">*Wiadomość jest za krótka.</span> <span class="empty">*To pole jest wymagane.</span> </label>
  20. </div>
  21. <div class="buttons-wrapper"> <a class="btn btn-1" data-type="reset">Wyczyść</a> <a class="btn btn-1" data-type="submit">Wyślij</a></div>
  22. <input type="submit" value="Wyślij" />
  23. </form>




  1. <?php
  2. $owner_email = $_POST["moj_mail"];
  3. $headers = 'From:' . $_POST["email"];
  4. $subject = 'A message from your site visitor ' . $_POST["name"];
  5. $messageBody = "";
  6.  
  7. if($_POST['name']!='nope'){
  8. $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
  9. $messageBody .= '<br>' . "\n";
  10. }
  11. if($_POST['email']!='nope'){
  12. $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
  13. $messageBody .= '<br>' . "\n";
  14. }else{
  15. $headers = '';
  16. }
  17. if($_POST['message']!='nope'){
  18. $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
  19. }
  20.  
  21. if($_POST["stripHTML"] == 'true'){
  22. $messageBody = strip_tags($messageBody);
  23. }
  24.  
  25. try{
  26. if(!mail($owner_email, $subject, $messageBody, $headers)){
  27. throw new Exception('mail failed');
  28. }else{
  29. echo 'mail sent';
  30. }
  31. }catch(Exception $e){
  32. echo $e->getMessage() ."\n";
  33. }
  34. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 23.06.2025 - 13:42