Witam!
Mam następujący problem: po wysłaniu za pomocą funkcji mail() emaila, którego treść pochodzi z formularza kontaktowego, dostaję na skrzynkę treść, bez polskich znaków. Wiem, że problem tkwi gdzieś w kodowaniu.
oto skrypt:
<?php
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="content-language" content="pl" />
</head>
<?php
$imie=$_POST['imie'];
$email=$_POST['email'];
$tresc=$_POST['tresc'];
$ID=$_POST['ID'];
if (($imie=="")||($email=="")||($tresc=="")||($ID==""))
{
header('Location: index.php?info=Nie wypełniono wszystkich pól'); }
else{
$sprawdz=$_SESSION['captcha'];
$kod = $_POST['ID'];
if ($kod==$sprawdz)
{
$poprawny_email=filter_var($email, FILTER_VALIDATE_EMAIL);
if ($poprawny_email!="")
{
$to = "wujekkk@vp.pl";
$subject = "Zapytanie wysłane ze strony biblioteki";
$message = "Pan/Pani ".$imie." Napisał/Napisała: \n \n".$tresc;
$headers = "MIME-Version: 1.0";
$headers .= "Content-type: text/html; charset=iso-8859-2";
$headers = "From: " . $email . "\n" . "Return-Path: " . $email . "\n" . "Reply-To: " . $email . "\n";
$submit = mail($to, $subject, $message, $headers); if ($submit)
header('Location: index.php?info=Wiadomość została wysłana'); else
header('Location: index.php?info=Wiadomości nie wysłano. Proszę ponowić próbę'); }
else
{
header('Location: index.php?info=Nieprawidłowy adres email'); }
}
else
{
header('Location: index.php?info=Wpisano niepoprawny kod'); }
}
?>
</html>
a oto formularz:
<FORM action="raz.php" Method="POST" accept-charset="iso-8859-2" onSubmit="return sprawdz(this);"> Twoje imię:
<INPUT NAME="imie"><br> Twój email:
<INPUT NAME="email"><br> Treść:
<textarea rows="4" cols="17" NAME="tresc"> Kod z obrazka:
<INPUT NAME="ID" size=5><br> <INPUT TYPE="submit" VALUE="Wyślij">
Dodam, że wyświetlając 'echem' $tresc w skrypcie wszystko jest ok, tzn są polskie znaki.
Pomożecie??
Problem rozwiązałem sam. Temat do zamknięcia!<?php
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="content-language" content="pl" />
</head>
<?php
$imie=$_POST['imie'];
$email=$_POST['email'];
$tresc=$_POST['tresc'];
$ID=$_POST['ID'];
if (($imie=="")||($email=="")||($tresc=="")||($ID==""))
{
header('Location: index.php?info=Nie wypełniono wszystkich pól'); }
else{
$sprawdz=$_SESSION['captcha'];
$kod = $_POST['ID'];
if ($kod==$sprawdz)
{
$poprawny_email=filter_var($email, FILTER_VALIDATE_EMAIL);
if ($poprawny_email!="")
{
$to = "wujekkk@vp.pl";
$subject = "Zapytanie wysłane ze strony biblioteki";
$message = "Pan/Pani ".$imie." Napisał/Napisała: \r\n \r\n".$tresc;
$message=nl2br($message);
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=ISO-8859-2\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers.= "From: " . $email . "\n" . "Return-Path: " . $email . "\n" . "Reply-To: " . $email . "\n";
$submit = mail($to, $subject, $message, $headers); if ($submit)
header('Location: index.php?info=Wiadomość została wysłana'); else
header('Location: index.php?info=Wiadomości nie wysłano. Proszę ponowić próbę'); }
else
{
header('Location: index.php?info=Nieprawidłowy adres email'); }
}
else
{
header('Location: index.php?info=Wpisano niepoprawny kod'); }
}
?>
</html>