Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript][HTML][PHP]Formularz PHP
overs
post
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 7.12.2010
Skąd: Białystok

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


Witam
Skorzystałem z poniższego skryptu PHP jak go zmodyfikować aby skrypt sprawdzał czy zostały zmienione domyśle pola value.
Jeżeli ich nie ma wszystko jest ok ale niestety musi tak zostać.

  1. <?php
  2. if (count($_POST))
  3. {
  4. ////////// USTAWIENIA //////////
  5. $email = 'e-mail'; // Adres e-mail adresata
  6. $subject = 'temat'; // 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 = 'utf-8'; // Strona kodowa
  10. //////////////////////////////
  11.  
  12. $head =
  13. "MIME-Version: 1.0\r\n" .
  14. "Content-Type: text/plain; charset=$charset\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. else
  31. {
  32. ?>

  1. <form action="?" method="post" id="form">
  2. <input type="text" id="name" name="name" value="Imię i Nazwisko:" onBlur="if(this.value=='') this.value='Imię i Nazwisko:';" onFocus="if(this.value=='Imię i Nazwisko:') this.value='';"/>
  3. </label>
  4. <input type="text" id="phone" name="phone" value="Telefon:" onBlur="if(this.value=='') this.value='Telefon:';" onFocus="if(this.value=='Telefon:') this.value='';"/>
  5. </label>
  6. <input type="text" id="mail" name="email" value="E-mail:" onBlur="if(this.value=='') this.value='E-mail:';" onFocus="if(this.value=='E-mail:') this.value='';"/>
  7. </label>
  8. <input value="Wyczyść" class="button" name="reset" type="reset" />
  9. <input value="Wyślij" class="button" name="submit" id="submit" type="submit" />
  10.  
  11.  
  12. </form>

  1. <?php
  2. }
  3. ?>
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: 3.10.2025 - 08:45