Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]formularz php
Forum PHP.pl > Forum > Przedszkole
marcin_sobota
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>
batman
Proszę poprawić bbcode.

Przenoszę na przedszkole i dodaję tag to tematu.
melkorm
  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 ... .
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.