Forum Webmastera, HTML, CSS, PHP, MySQL, Hosting, Domeny - Forum dla Webmasterów
Formularz email PHP - pomoc z konfiguracją - Wersja do druku

+- Forum Webmastera, HTML, CSS, PHP, MySQL, Hosting, Domeny - Forum dla Webmasterów (https://www.webmastertalk.pl)
+-- Dział: Technologie internetowe - tworzenie stron WWW (https://www.webmastertalk.pl/forum-technologie-internetowe-tworzenie-stron-www)
+--- Dział: xHTML, CSS, JavaScript (https://www.webmastertalk.pl/forum-xhtml-css-javascript)
+--- Wątek: Formularz email PHP - pomoc z konfiguracją (/thread-formularz-email-php-pomoc-z-konfiguracja)



Formularz email PHP - pomoc z konfiguracją - kulig9 - 12-08-2010

SiemaSmile Słuchajcie, mam taki formularz na stronę, ma on być na każdej stronie w wysuwanym panelu, jednak nie chcę żeby kazda strona przez to musiała być zapisana jako php , tylko html! Dlatego zmieniłem go troszkę, żeby w plikach html był sam formularz i żeby odwoływał sie do oddzielnego pliku "wyslij.php".

ORYGINALNY:
Kod:
<?php
if (count($_POST))
{
   ////////// USTAWIENIA //////////
   $email = 'email';   // Adres e-mail adresata
   $subject = 'Formularz kontaktowy';   // Temat listu
   $message = 'Dziękuję 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">

<table>
<tr>
<td>Imię i nazwisko: </td><td><input type="nick" name="nick" size="30" /></td>
</tr>
<tr>
<td>Twój e-mail: </td><td><input type="email" name="email" size="30" /></td>
</tr>
<tr>
<td valign=top>Tre¶ć: </td><td><textarea type="tresc" name="tresc" cols="30" rows="10"></textarea></td>
</tr>
</table><BR>
<table>
<td>
   <input type="submit" value="Wy¶lij" />
</td>
<td>
   <input type="reset" value="Wyczy¶ć" />
</td>
</table>

</form>
<?php
}
?>


PODZIELONY:
w pliku html:
Kod:
<form action="wyslij.php" method="post">

<table>
<tr>
<td>Imię i nazwisko: </td><td><input type="nick" name="nick" size="25" /></td>
</tr>
<tr>
<td>Twój e-mail: </td><td><input type="email" name="email" size="25" /></td>
</tr>
<tr>
<td valign=top>Treść: </td><td><textarea type="tresc" name="tresc" cols="25" rows="10"></textarea></td>
</tr>
</table><BR>
<table>
<td>
   <input type="submit" value="Wyślij" />
</td>
<td>
   <input type="reset" value="Wyczyść" />
</td>
</table>

</form>

wyslij.php:
Kod:
    <?php
if (count($_POST))
{
   ////////// USTAWIENIA //////////
   $email = 'email';   // Adres e-mail adresata
   $subject = 'Formularz kontaktowy';   // Temat listu
   $message = 'Dziękuję za wysłanie formularza';   // Komunikat
   $error = 'Wystąpił błąd podczas wysyłania formularza';   // Komunikat błędu
   $charset = 'UTF-8';   // 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
{
?>

Jednak teraz pojawił się taki problem, że potwierdzenie, że email został wysłany pojawia się w nowym oknie, a nie pod formularzem:// Czy mozna np zrobić żeby ten komunikat, że email został nadany pojawiał się w okienku POP-UNDER ?? Bo to byloby idealnym rozwiązaniem..