Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Sprawdzenie formularza, Mam taki problem z formularzem
adziozone
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 26.02.2011

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


Witam,

Mam taki problem z formularzem, chciałbym żeby była w nim funkcja taka ze jak jakaś rubryka nie jest uzupełniona to żeby poniżej wyświetlał się komunikat np. „wypełnij wszystkie rubryki” z góry dzięki za pomoc.

<?php
if (count($_POST))
{
////////// USTAWIENIA //////////
$email = 'adziozone@op.pl'; // Adres e-mail adresata
$subject = ' kontakt'; // Temat listu
$message = 'Dziękujemy za wysłanie formularza'; // Komunikat
$error = 'Wystąpił błąd podczas wysyłania formularza'; // Komunikat błędu
$charset = 'iso-8859-2'; // Strona kodowa
//////////////////////////////

$head =
"MIME-Version: 1.0\r\n" .
"Content-Type: text/plain; charset=$charset\r\n" .
"Content-Transfer-Encoding: 8bit";
$body = '';
foreach ($_POST as $name => $value)
{
if (is_array($value))
{
for ($i = 0; $i < count($value); $i++)
{
$body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . "\r\n";
}
}
else $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . "\r\n";
}
echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message : $error;
}
else
{
?>
<form action="?" method="post">

<!-- Komentarz -->
<p align="right">
<b>
<font size="3" color="#ffffff">Imię i nazwisko:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</b>
<font color="#000080">
<input maxLength="24" name="Imię i nazwisko:[]" size="30" style="font-weight: 700" value="<?= $imie; ?>" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font>
<br><br>
<b>
<font size="3" color="#ffffff">Adres e-mai:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</b>
<font color="#000080">
<input maxLength="29" name="Adres -mail:[]" size="30" style="font-weight: 700" value="<?= $adres; ?>" >
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
</font>
<br>
<b>
<font size="3" color="#ffffff">Telefon:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</b>
<font color="#000080">
<input maxLength="29" name="Telfon:[]" size="30" style="font-weight: 700" value="<?= $telefon; ?>">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
</font>
<br>
</p>
<p align="right">
&nbsp;&nbsp;&nbsp;
<b>
<font size="3" color="#ffffff">Treść:
</b>
</font>
<textarea rows="8" name="tresc[]" cols="40"></textarea>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
&nbsp;&nbsp;&nbsp;
<br>
<center>
<input type="submit" name="wyslij" value="Wyślij" style="background-color: #000000; font-family: Verdana; color: #FFFFFF; font-size: 8pt; font-weight: bold; border: 1px solid #FFFFFF; ">
&nbsp;&nbsp;&nbsp;
<input type="reset" name="reset" value="Wyczyść" style="background-color: #000000; font-family: Verdana; color: #FFFFFF; font-size: 8pt; font-weight: bold; border: 1px solid #FFFFFF; ">
</center>
<input type="hidden" name="location" value="dziekuje.htm">

</form>
<?php
}
?>




Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Aqu
post
Post #2





Grupa: Zarejestrowani
Postów: 279
Pomógł: 58
Dołączył: 14.07.2012

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


Coś takiego:
  1.  
  2. <?php
  3. if (isset($_POST['Imię i nazwisko:'], $_POST['Imię i nazwisko:'], $_POST['Telfon:'], $_POST['tresc']))
  4. {
  5. ////////// USTAWIENIA //////////
  6. $email = 'adziozone@op.pl'; // Adres e-mail adresata
  7. $subject = ' kontakt'; // Temat listu
  8. $message = 'Dziękujemy za wysłanie formularza'; // Komunikat
  9. $error = 'Wystąpił błąd podczas wysyłania formularza'; // Komunikat błędu
  10. $charset = 'iso-8859-2'; // Strona kodowa
  11. //////////////////////////////
  12.  
  13. $head =
  14. "MIME-Version: 1.0\r\n" .
  15. "Content-Type: text/plain; charset=$charset\r\n" .
  16. "Content-Transfer-Encoding: 8bit";
  17. $body = '';
  18. foreach ($_POST as $name => $value)
  19. {
  20. if (is_array($value))
  21. {
  22. for ($i = 0; $i < count($value); $i++)
  23. {
  24. $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . "\r\n";
  25. }
  26. }
  27. else $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . "\r\n";
  28. }
  29. echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message : $error;
  30. }
  31. else
  32. {
  33. if(isset($_POST)) echo 'Uzupełnij wszystkie pola.';
  34. ?>
  35. <form action="?" method="post">
  36.  
  37. <!-- Komentarz -->
  38. <p align="right">
  39. <b>
  40. <font size="3" color="#ffffff">Imię i nazwisko:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  41. </b>
  42. <font color="#000080">
  43. <input maxLength="24" name="Imię i nazwisko:[]" size="30" style="font-weight: 700" value="<?= $imie; ?>" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  44. </font>
  45. <br><br>
  46. <b>
  47. <font size="3" color="#ffffff">Adres e-mai:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  48. </b>
  49. <font color="#000080">
  50. <input maxLength="29" name="Adres -mail:[]" size="30" style="font-weight: 700" value="<?= $adres; ?>" >
  51. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
  52. </font>
  53. <br>
  54. <b>
  55. <font size="3" color="#ffffff">Telefon:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  56. </b>
  57. <font color="#000080">
  58. <input maxLength="29" name="Telfon:[]" size="30" style="font-weight: 700" value="<?= $telefon; ?>">
  59. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
  60. </font>
  61. <br>
  62. </p>
  63. <p align="right">
  64. &nbsp;&nbsp;&nbsp;
  65. <b>
  66. <font size="3" color="#ffffff">Treść:
  67. </b>
  68. </font>
  69. <textarea rows="8" name="tresc[]" cols="40"></textarea>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
  70. &nbsp;&nbsp;&nbsp;
  71. <br>
  72. <center>
  73. <input type="submit" name="wyslij" value="Wyślij" style="background-color: #000000; font-family: Verdana; color: #FFFFFF; font-size: 8pt; font-weight: bold; border: 1px solid #FFFFFF; ">
  74. &nbsp;&nbsp;&nbsp;
  75. <input type="reset" name="reset" value="Wyczyść" style="background-color: #000000; font-family: Verdana; color: #FFFFFF; font-size: 8pt; font-weight: bold; border: 1px solid #FFFFFF; ">
  76. </center>
  77. <input type="hidden" name="location" value="dziekuje.htm">
  78.  
  79. </form>
  80. <?php
  81. }
  82. ?>


Ale może lepiej skorzystać z jakiegoś gotowego skryptu?

Ten post edytował Aqu 22.08.2012, 18:16:05
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: 12.10.2025 - 04:47