Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]formularz php, mailto
marcin_sobota
post
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 27.09.2008

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


witam

mam formularz php mailto

i nie potrafie zrobic zeby ni wysylalo maila jezeli moje pola sa puste. abo jakiegos brakuje o to mj skrpt

<?php
if (count($_POST))
{
////////// USTAWIENIA //////////
$email = 'xxx@xx.xx'; // Adres e-mail adresata
$subject = 'Korespondencja xxx'; // Temat listu
$message = 'Thank You for Your letter'; // Komunikat
$error = 'An error occured during sending the e-mail. Pleas try again'; // 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">


Name: <br><input type="text" name="Name" size="20"></textarea> <br>
Surname: <br><input type="text" name="Surname" size="20"></textarea> <br>
E-mail:<br><input type="text" name="E-mail" size="20"></textarea> <br>
Comemnts:<br><textarea name="Comments" cols="50" rows="4" wrap="physical"></textarea> <br>

<div id="dalej">
<input type="submit" name="ok" value="Send">
</div>
Go to the top of the page
+Quote Post
batman
post
Post #2





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Proszę poprawić bbcode.

Przenoszę na przedszkole i dodaję tag to tematu.
Go to the top of the page
+Quote Post
melkorm
post
Post #3





Grupa: Zarejestrowani
Postów: 1 366
Pomógł: 261
Dołączył: 23.09.2008
Skąd: Bydgoszcz

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


  1. <?php
  2. if ($_POST['ok']) {
  3.    ////////// USTAWIENIA //////////
  4.    $email = 'xxx@xx.xx'; // Adres e-mail adresata
  5.    $subject = 'Korespondencja xxx'; // Temat listu
  6.    $message = 'Thank You for Your letter'; // Komunikat
  7.    $error = 'An error occured during sending the e-mail. Pleas try again'; // Komunikat błędu
  8.    $charset = 'iso-8859-2'; // Strona kodowa
  9.    //////////////////////////////
  10.    
  11.    $head =
  12.    "MIME-Versio: 1.0r\n" .
  13.    "Content-Typ: text/plain; charset=$charsetr\n" .
  14.    "Content-Transfer-Encodin: 8bit";
  15.    $body = '';
  16.    
  17.    foreach ($_POST as $name => $value) {
  18.        if(!empty($value)) {
  19.            if (is_array($value)) {
  20.                foreach($value as $val) {
  21.                    $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($val)&nbsp: $val) . "r\n";
  22.                }
  23.            }
  24.            else $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value)&nbsp: $value) . "r\n";
  25.        } else $error = true;
  26.    }
  27.    if(!$error) {
  28.        echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message $error;
  29.    }
  30. }
  31. else&nbsp: ?>
  32. <form action="?" method="post">
  33. Nam: <br><input type="text" name="Name" size="20"><br>
  34. Surnam: <br><input type="text" name="Surname" size="20"> <br>
  35. E-mail:<br><input type="text" name="E-mail" size="20"><br>
  36. Comemnt:<br><textarea name="Comments" cols="50" rows="4"></textarea> <br>
  37. <div id="dalej">
  38.    <input type="submit" name="ok" value="Send">
  39. </div>
  40. <?php endif?>


Na szybko poprawione ... .
Go to the top of the page
+Quote Post

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: 23.08.2025 - 05:10