Kod
<?php
if (count($_POST))
{
////////// USTAWIENIA //////////
$email = 'adres e-mail gdzie wysłać formularz'; // Adres e-mail adresata
$subject = 'temat'; // Temat listu
$message = '[b]Dziękujemy za wysłanie formularza[/b]'; // Komunikat
$error = '[b]Wystąpił błąd podczas wysyłania formularza[/b]'; // Komunikat błędu
$charset = '[b]iso-8859-2[/b]'; // 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">
Tutaj umieść wszystkie pola formularza
</form>
<?php
}
if (count($_POST))
{
////////// USTAWIENIA //////////
$email = 'adres e-mail gdzie wysłać formularz'; // Adres e-mail adresata
$subject = 'temat'; // Temat listu
$message = '[b]Dziękujemy za wysłanie formularza[/b]'; // Komunikat
$error = '[b]Wystąpił błąd podczas wysyłania formularza[/b]'; // Komunikat błędu
$charset = '[b]iso-8859-2[/b]'; // 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">
Tutaj umieść wszystkie pola formularza
</form>
<?php
}
jednak chciałbym zamiast komunikatu
Dziękujemy za wysłanie formularza
w razie poprawnego wysłania, przenieść użytkownika na stronę : podziekowanie.php . Wiem, że do przenoszenia używa się funkcji: header("Location: http://www.example.com/something.php?a=1"); jednak nie wiem gdzie to wstawić aby zadziałało...