Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML][PHP]Jak umieścić checkbox w wiadomości email
brt00
post 19.08.2014, 14:55:41
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 4.06.2013

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


Witam, mam swój formularz w pliku html:
  1. <form action="wypelnij_formularz.php" method="post" id="sky-form" class="sky-form">
  2.           <fieldset>
  3.               <section class="col col-6">
  4.                 <label class="label">Imię / Nazwa firmy *</label>
  5.                 <label class="input">
  6.                   <input type="text" name="name" id="name">
  7.                 </label>
  8.                 <label class="label">Numer telefonu *</label>
  9.                 <label class="input">
  10.                   <input type="text" name="nr" id="nr">
  11.                 </label>
  12.                 <label class="label">Adres email</label>
  13.                 <label class="input">
  14.                   <input type="email" name="email" id="email">
  15.                 </label>
  16.                 <label class="label">Wiadomość</label>
  17.               <label class="textarea">
  18.                 <textarea rows="4" name="message" id="message"></textarea>
  19.               </label>
  20.               <label class="checkbox"><input type="checkbox" name="zgoda" id="zgoda"><i></i>Wyrażam zgodę.</label>
  21.               </section>
  22.               <section class="col col-6">
  23.                 <label class="label">Temat *</label>
  24.                 <label class="checkbox"><input type="checkbox" name="poz1" id="poz1"><i></i>POZ1</label>
  25.                 <label class="checkbox"><input type="checkbox" name="poz2" id="poz2"><i></i>POZ2</label>
  26.                 <label class="checkbox"><input type="checkbox" name="sklep" id="sklep"><i></i>POZ3</label>
  27.               </section>
  28.           </fieldset>
  29.           <footer>
  30.             <button action="wypelnij_formularz.php" method="post" type="submit" class="button">Wyślij</button>
  31.             <p style="float:right">Pola oznaczone * są obowiązkowe</p>
  32.           </footer>
  33.         </form>


I plik PHP, który odpowiada za wysyłkę maila:
  1. <?php
  2. if( isset($_POST['name']) )
  3. {
  4.     $to = 'biuro@strona.pl';
  5.    
  6.     $subject = 'Setbrand.pl | formularz kontaktowy';
  7.     $message = $_POST['message'] . "\n\n" . 'Imię / Nazwa firmy: ' . $_POST['name'] . '.' . "\n\n" . 'Numer telefonu: ' . $_POST['nr'] . '.' . "\n\n" . 'Email: ' . $_POST['email'] . '.';
  8.     $headers = 'From: ' . $_POST['name'] . "\r\n" . 'Reply-To: ' . $_POST['email'] . "\r\n" . 'X-Mailer: PHP/' . phpversion();
  9.     mail($to, $subject, $message, $headers);
  10.     if( $_POST['copy'] == 'on' )
  11.     {
  12.         mail($_POST['email'], $subject, $message, $headers);
  13.     }
  14. }
  15. ?>


Moje pytanie brzmi następująco: Jak dodać do pliku PHP kod, żeby w mailu wyświetlało się które pola checkbox użytkownik zaznaczył (chodzi o temat: POZ1 POZ2 POZ3). Jeśli to możliwe proszę o kawałek kodu, który będę musiał wkleić prawdopodobnie w linii z $message.
Go to the top of the page
+Quote Post
luniak
post 19.08.2014, 16:02:37
Post #2





Grupa: Zarejestrowani
Postów: 171
Pomógł: 36
Dołączył: 12.01.2008
Skąd: Puszcza Mariańska

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


  1.  
  2. $message .= (isset($_POST['poz1']) ? "poz1 zaznaczone\n\r" : "" );
  3. $message .= (isset($_POST['poz2']) ? "poz2 zaznaczone\n\r" : "" );
  4. $message .= (isset($_POST['poz3']) ? "poz3 zaznaczone\n\r" : "" );
  5.  



--------------------
Jeżeli ktoś na forum Ci pomógł, możesz mu podziękować klikając w opcje "Pomógł" pod jego postem!
--------------------

Go to the top of the page
+Quote Post
brt00
post 19.08.2014, 16:32:08
Post #3





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 4.06.2013

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


Dziękuję bardzo za pomoc. Jestem zobowiązany.

Mam jeszcze jeden problem, mianowicie po kliknięciu wyślij wysyła mi formularz, ale na podstronie on znika i zostaje wszystko bez formularza. Czy mogę tam wstawić w jakiś sposób tekst w stylu: "Dziękujemy za wysłanie formularza"?
Go to the top of the page
+Quote Post
luniak
post 19.08.2014, 17:06:51
Post #4





Grupa: Zarejestrowani
Postów: 171
Pomógł: 36
Dołączył: 12.01.2008
Skąd: Puszcza Mariańska

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


Znika bo jest to inny plik smile.gif
Albo na końcu swojej wysyłki

  1. <?php
  2. if( isset($_POST['name']) )
  3. {
  4. $to = 'biuro@strona.pl';
  5.  
  6. $subject = 'Setbrand.pl | formularz kontaktowy';
  7. $message = $_POST['message'] . "\n\n" . 'Imię / Nazwa firmy: ' . $_POST['name'] . '.' . "\n\n" . 'Numer telefonu: ' . $_POST['nr'] . '.' . "\n\n" . 'Email: ' . $_POST['email'] . '.';
  8. $headers = 'From: ' . $_POST['name'] . "\r\n" . 'Reply-To: ' . $_POST['email'] . "\r\n" . 'X-Mailer: PHP/' . phpversion();
  9. mail($to, $subject, $message, $headers);
  10. if( $_POST['copy'] == 'on' )
  11. {
  12. mail($_POST['email'], $subject, $message, $headers);
  13. }
  14. }
  15. ?>
  16. Dodaj tu tekst


... dodajesz tekst, albo ...

  1. header("Location: /adres_formualrza.html"); die;


... i wtedy wróci ci na "adres_formualrza.html"


--------------------
Jeżeli ktoś na forum Ci pomógł, możesz mu podziękować klikając w opcje "Pomógł" pod jego postem!
--------------------

Go to the top of the page
+Quote Post
brt00
post 20.08.2014, 16:31:51
Post #5





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 4.06.2013

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


Niestety wtedy po wysłaniu wyświetla się biała strona z treścią:
  1. header("Location: /kontakt.html"); die;
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 Wersja Lo-Fi Aktualny czas: 1.05.2024 - 21:45