Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] problem z formularzem
banki
post
Post #1





Grupa: Zarejestrowani
Postów: 109
Pomógł: 1
Dołączył: 23.11.2007

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


Witam,

mam problem z formularzem, w ktorego wrzuciłem opcję wyboru do jakiego działu ma iść email, problem w tym że obojętnie co zaznaczę idzie mi na email1, jak zaznacze dział 2 to powinno pojść na email2 a idzie na email1, widzicie może jakieś błędy w tym kodzie?

  1.  
  2. <form action="form.php" method="post" name="form" id="form" onsubmit="usun_pl(this)" accept-charset="utf-8">
  3. <select name="dzial" class="input_kontakt" />
  4. <option value="dzial1">dział 1</option>
  5. <option value="dzial2">dział 2</option>
  6. </form>
  7.  



początek form.php
  1. if (count($_POST['dzial'] == 'dzial1'))
  2.  
  3. {
  4. ////////// USTAWIENIA //////////
  5. $email = 'email1@wp.pl'; // Adres e-mail adresata
  6. $subject = 'formularz ze strony'; // Temat listu
  7. $message = ''; // Komunikat
  8. $error = ''; // Komunikat błędu
  9. $charset = 'utf-8'; // Strona kodowa
  10. //////////////////////////////
  11.  
  12. $head =
  13. "MIME-Version: 1.0\r\n" .
  14. "Content-Type: text/plain; charset='utf-8'\r\n" .
  15. "Content-Transfer-Encoding: 8bit";
  16. $body = '';
  17. foreach ($_POST as $name => $value)
  18. {
  19. if (is_array($value))
  20. {
  21. for ($i = 0; $i < count($value); $i++)
  22. {
  23. $body .= "$name = " . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . "\r\n";
  24. }
  25. }
  26. else $body .= "$name = " . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . "\r\n";
  27. }
  28. echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message : $error;
  29. }
  30.  
  31. else if(count($_POST['dzial'] == 'dzial2'))
  32.  
  33. {
  34. ////////// USTAWIENIA //////////
  35. $email = 'email2@wp.pl'; // Adres e-mail adresata
  36. $subject = 'formularz ze strony'; // Temat listu
  37. $message = ''; // Komunikat
  38. $error = ''; // Komunikat błędu
  39. $charset = 'utf-8'; // Strona kodowa
  40. //////////////////////////////
  41.  
  42. $head =
  43. "MIME-Version: 1.0\r\n" .
  44. "Content-Type: text/plain; charset='utf-8'\r\n" .
  45. "Content-Transfer-Encoding: 8bit";
  46. $body = '';
  47. foreach ($_POST as $name => $value)
  48. {
  49. if (is_array($value))
  50. {
  51. for ($i = 0; $i < count($value); $i++)
  52. {
  53. $body .= "$name = " . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . "\r\n";
  54. }
  55. }
  56. else $body .= "$name = " . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . "\r\n";
  57. }
  58. echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message : $error;
  59. }
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: 20.09.2025 - 15:19