Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [AJAX][PHP] Błąd w formularzu
Michalo1994
post
Post #1





Grupa: Zarejestrowani
Postów: 93
Pomógł: 0
Dołączył: 3.02.2009

Ostrzeżenie: (20%)
X----


Mam darmowy skrypt PHP&ajax - formularz kontaktowy. Niestety po wrzuceniu na hosting home.pl - nie działa - wyświetla się komunikat "spróbuj ponownie".
Mógłby mi ktoś pomóc w znalezieniu przyczyny? Kod php formularza poniżej:
  1. <?php
  2.  
  3. // Define some constants
  4. define( "RECIPIENT_NAME", "Imię i nazwisko" );
  5. define( "RECIPIENT_EMAIL", "moj.email@ow.pl" );
  6. define( "EMAIL_SUBJECT", "Zapytanie" );
  7.  
  8. // Read the form values
  9. $success = false;
  10. $senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
  11. $senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
  12. $message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
  13.  
  14. // If all values exist, send the email
  15. if ( $senderName && $senderEmail && $message ) {
  16. $recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
  17. $headers = "From: " . $senderName . " <" . $senderEmail . ">";
  18. $success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
  19. }
  20.  
  21. // Return an appropriate response to the browser
  22. if ( isset($_GET["ajax"]) ) {
  23. echo $success ? "success" : "error";
  24. } else {
  25. ?>
  26. <html>
  27. <head>
  28. <title>Dziękujemy!</title>
  29. </head>
  30. <body>
  31. <?php if ( $success ) echo "<p>Wiadomość wysłana!.</p>" ?>
  32. <?php if ( !$success ) echo "<p>Spróbuj ponownie.</p>" ?>
  33. <p>Kliknij wstecz aby wrócić.</p>
  34. </body>
  35. </html>
  36. <?php
  37. }
  38. ?>


Ten post edytował Michalo1994 20.08.2014, 20:50:52
Go to the top of the page
+Quote Post
trueblue
post
Post #2





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


https://pomoc.home.pl/komunikaty/1067


--------------------
Go to the top of the page
+Quote Post
Michalo1994
post
Post #3





Grupa: Zarejestrowani
Postów: 93
Pomógł: 0
Dołączył: 3.02.2009

Ostrzeżenie: (20%)
X----


Dzięki za odpowiedź.
Zmieniłem funkcję mail tak:
  1. $success = mail( $recipient, EMAIL_SUBJECT, $message, $headers, "-f biuro@domena.pl" );

biuro@domena.pl - to jest mój e-mail z usług home.pl. Jednak cały czas nie działa.
Jest jeszcze jakieś wyjście?

Ten post edytował Michalo1994 20.08.2014, 22:25:29
Go to the top of the page
+Quote Post
trueblue
post
Post #4





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Zmień tu drugi adres na wspomniany adres w domenie:
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
Aby odpowiadać do rzeczywistego nadawcy dodaj pole ReplyTo.

P.S. Mam nadzieję, że zmieniłeś na faktyczny adres, a nie dokładnie biuro@domena.pl.


--------------------
Go to the top of the page
+Quote Post
Michalo1994
post
Post #5





Grupa: Zarejestrowani
Postów: 93
Pomógł: 0
Dołączył: 3.02.2009

Ostrzeżenie: (20%)
X----


Dzięki za odpowiedź. OCzywiście - w mailu jest mój firmowy mail - który mam również podpięty w home.pl.
Zmieniłem - nie pomogło. Usunąłem całą zmienną $headers - również. Ma ktoś jakiś pomysł lub skrypt formularza, który działa na home.pl? Będę bardzo wdzięczny
Go to the top of the page
+Quote Post
trueblue
post
Post #6





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Zmiennej $headers nie sugerowałem aby usuwać, chyba, że to Twój pomysł.
Najlepiej jakbyś wrzucił tu zmieniony kod.


--------------------
Go to the top of the page
+Quote Post
Michalo1994
post
Post #7





Grupa: Zarejestrowani
Postów: 93
Pomógł: 0
Dołączył: 3.02.2009

Ostrzeżenie: (20%)
X----


Wszystko mam tak samo - zmieniłem tylko linijkę
  1. $headers = "From: " . $senderName . " <" . $senderEmail . ">";

na
  1. $headers = "From: " . $senderName . " <" . biuro@domena.pl . ">";

Go to the top of the page
+Quote Post
trueblue
post
Post #8





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Raczej tak:
  1. $headers = "From: " . $senderName . " <biuro@domena.pl>";


--------------------
Go to the top of the page
+Quote Post
Michalo1994
post
Post #9





Grupa: Zarejestrowani
Postów: 93
Pomógł: 0
Dołączył: 3.02.2009

Ostrzeżenie: (20%)
X----


Niestety cały czas wyświetla się 'Spróbuj ponownie' sad.gif
Go to the top of the page
+Quote Post
trueblue
post
Post #10





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Spreparuj najprostszy skrypt do wysyłki i przetestuj (bez ifów, html i innych).


--------------------
Go to the top of the page
+Quote Post

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 Aktualny czas: 22.08.2025 - 01:12