Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> formularz kontaktowy, kompilacja z dwóch form
mixter
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 30.11.2008

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


Cześć wszystkim.
Na swojej stronce mam form, który sprawdza czy wszystkie pola zostały wypełnione ale wysyłał mi krzaki. Szukałam i znalazłam taki który wysyła polskie znaki. No i tu są schody, bo umiem programować tylko w html i css a php dopiero się uczę.
Właśnie próbuje skompilować dwa formularze do wysyłania wiadomości. Jeden z nich pozwala na sprawdzanie czy pola formularza są wypełnione i na nim chciałam oprzeć swój formularz ponieważ wysyła mi wiadomość w ładniejszej formie.
  1. <?php
  2. [/b]if (empty($_POST['submit'])) {
  3.  
  4.  
  5.  
  6.    echo "<form method=\"post\" action=\"\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
  7.  
  8. <tr>
  9. <td>Imię</td></tr>
  10. <tr><td><input type=\"text\" name=\"imie\" class=\"formfield large\"></td>
  11. </tr>
  12. <tr>
  13. <td>Nazwisko</td></tr>
  14. <tr><td><input type=\"text\" name=\"nazwisko\" class=\"formfield large\"></td>
  15. </tr>
  16. <tr>
  17. <td>Adres e-mail</td> </tr>
  18. <tr><td><input type=\"text\" name=\"email\" class=\"formfield large\"></td>
  19. </tr>
  20. <tr>
  21. <td>Telefon</td> </tr>
  22. <tr><td><input type=\"text\" name=\"telefon\" class=\"formfield large\"></td>
  23. </tr>
  24.      <tr>
  25. <td>Treść wiadomości</td> </tr>
  26. <tr><td><textarea name=\"tresc\" class=\"formfield textarea\" rows=\"1\" cols=\"1\"></textarea></td>
  27. </tr>
  28.  
  29. <tr>
  30.  
  31. <td><input type=\"submit\" name=\"submit\" value=\"Wyślij\" class=\"submitbutton\"></td></tr>
  32.  
  33. </table></form>";
  34. }
  35.  
  36. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email']) && !empty($_POST['telefon']) && !empty($_POST['nazwisko'])) {
  37.    $message = "$_POST[imie]\n$_POST[nazwisko]\ne-mail: $_POST[email]\ntelefon: $_POST[telefon]\ntreść:$_POST[tresc]";
  38.    $header = "From: $_POST[imie] $_POST[nazwisko] <$_POST[email]>";
  39.    @mail("ko@c.com","Wiadomosc ze strony WWW","$message","$header")
  40.    or die('Nie udało się wysłać wiadomości');
  41.  
  42.      echo "<form method=\"post\" action=\"\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
  43.  
  44. <tr>
  45. <td>Imię</td></tr>
  46. <tr><td><input type=\"text\" name=\"imie\" class=\"formfield large\"></td>
  47. </tr>
  48. <tr>
  49. <td>Nazwisko</td></tr>
  50. <tr><td><input type=\"text\" name=\"nazwisko\" class=\"formfield large\"></td>
  51. </tr>
  52. <tr>
  53. <td>Adres e-mail</td> </tr>
  54. <tr><td><input type=\"text\" name=\"email\" class=\"formfield large\"></td>
  55. </tr>
  56. <tr>
  57. <td>Telefon</td> </tr>
  58. <tr><td><input type=\"text\" name=\"telefon\" class=\"formfield large\"></td>
  59. </tr>
  60.      <tr>
  61. <td>Treść wiadomości</td> </tr>
  62. <tr><td><textarea name=\"tresc\" class=\"formfield textarea\" rows=\"1\" cols=\"1\"></textarea></td>
  63. </tr>
  64.  
  65. <tr>
  66.  
  67. <td><input type=\"submit\" name=\"submit\" value=\"Wyślij\" class=\"submitbutton\"></td></tr>
  68.  
  69. </table></form>";
  70.  
  71.    echo "<div align=\"center\"><strong>Dziękujemy za wysłanie wiadomości.</strong></div>";
  72. }
  73. else echo "<span style=\"color: #FF0000; text-align: center;\">Wypełnij wszystkie pola formularza!</span>";
  74.  
  75. ?>


no i drugi, który niweluje krzaki.
[b]
  1. <?php
  2. if (count($_POST))
  3. {
  4.   ////////// USTAWIENIA //////////
  5.   $email = [email=""]'ko@c.com'[/email];   // Adres e-mail adresata
  6.   $subject = 'Wiadomość ze strony www';   // Temat listu
  7.   $message = 'Dziękujemy za wysłanie formularza';   // Komunikat
  8.   $error = 'Wystąpił błąd podczas wysyłania formularza';   // Komunikat błędu
  9.   $charset = 'iso-8859-2';   // Strona kodowa
  10.   //////////////////////////////
  11.    
  12.   $head =
  13.      "MIME-Version: 1.0r\n" .
  14.      "Content-Type: text/plain; charset=$charsetr\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. else
  31. {
  32. ?>
  33. <form action="?" method="post">
  34.  
  35. <table border="0" cellpadding="0" cellspacing="0">
  36.  
  37. <tr>
  38. <td>Imię</td></tr>
  39. <tr><td><input type="text" name="imie" class="formfield large"></td>
  40. </tr>
  41. <tr>
  42. <td>Nazwisko</td></tr>
  43. <tr><td><input type="text" name="nazwisko" class="formfield large"></td>
  44. </tr>
  45. <tr>
  46. <td>Adres e-mail</td> </tr>
  47. <tr><td><input type="text" name="email" class="formfield large"></td>
  48. </tr>
  49. <tr>
  50. <td>Telefon</td> </tr>
  51. <tr><td><input type="text" name="telefon" class="formfield large"></td>
  52. </tr>
  53.      <tr>
  54. <td>Treść wiadomości</td> </tr>
  55. <tr><td><textarea name="tresc" class="formfield textarea" rows="1" cols="1"></textarea></td>
  56. </tr>
  57.  
  58. <tr>
  59.  
  60. <td><input type="submit" name="submit" value="Wyślij" class="submitbutton"></td></tr>
  61.  
  62. </table>
  63.  
  64. </form>
  65. <?php
  66. }
  67. ?>


z tego drugiego chciałam przenieść właśnie to co niweluje krzaki. Niestety dopiero uczę się PHP i do tej pory pisałam stronki w html i css. Czy mógłby mi ktoś pomóc w tej kompilacji. W który miejscu i co przenieść z drugiego skryptu do pierwszego. Będę bardzo wdzięczna za pomoc
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.09.2025 - 17:49