Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $twojemail = "xxx@o2.pl"; //na jaki adres ma zostać wysłana treść z formularza
- $blad=0;
- if (isset($_POST['submit'])) {
- // filtrowanie treści wprowadzonych przez użytkownika
- $name = htmlspecialchars(stripslashes(strip_tags(trim($_POST["name"]))), ENT_QUOTES);
- $email = htmlspecialchars(stripslashes(strip_tags(trim($_POST["email"]))), ENT_QUOTES);
- $message = htmlspecialchars(stripslashes(strip_tags(trim($_POST["message"]))), ENT_QUOTES);
- $temat = 'Kontakt';
- $ip = $_SERVER['REMOTE_ADDR'];
- // sprawdzamy czy wszystkie pola zostały wypełnione
- if (!$name) {
- $blad++;
- echo 'Prosimy wpisać nick.';
- }
- if (!$email) {
- $blad++;
- echo 'Prosimy wpisać adres E-mail.';
- }
- if (!$message) {
- $blad++;
- echo 'Prosimy wpisać treść wiadomości.';
- }
- // jeżeli nie ma błędu, to wiadomość e-mail zostaje wysłana
- if ($blad == 0) {
- // niezbędne nagłówki do wyświetlania wiadomości HTML
- $naglowki = "MIME-Version: 1.0" . "\r\n";
- $naglowki .= "Content-type:text/html;charset=utf-8" . "\r\n";
- // opcjonalne nagłówki
- $naglowki .= 'From: <'.$email.'>' . "\r\n";
- $naglowki .= 'Cc: <'.$twojemail.'>' . "\r\n";
- // całkowita treść wiadomości
- $message = nl2br($message);
- $wiadomosc = <<< KONIEC
- <html>
- <strong>Imie:</strong> $name<br />
- <strong>E-mail:</strong> $email<br />
- <strong>IP:</strong> $ip <br />
- <strong>Wiadomość:</strong><br /> $message
- </html>
- KONIEC;
- // wysyłanie wiadomości e-mail
- $wynik = mail('<'.$twojemail.'>', $temat, $wiadomosc, $naglowki);
- // komunikat potwierdzający wysłanie wiadomości bądź nie
- if ($wynik) {
- echo 'Wiadomość została wysłana.';
- } else {
- echo 'Wystąpił bład.';
- }
- }
- }
- ?>
- <div class="row">
- <form method="post" name="contactform" action="kontakt.php">
- <div class="col-sm-6">
- <div class="form-group">
- <font size="2">Imie<br />
- <input type="text" name="name" id="name" class="form-control">
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- E-mail<br />
- <input type="text" name="email" id="email" class="form-control">
- </div>
- </div>
- <div class="col-sm-12">
- <div class="textarea-message form-group">
- Treść wiadomości</font><br />
- <textarea name="message" id="message" class="textarea-message form-control" rows="7" cols="27"></textarea>
- </div>
- </div>
- <div class="text-center">
- <button type="submit" name="submit" value="Send message" class="button button-style button-style-dark button-style-icon fa fa-long-arrow-right text-center">Wyślij wiadomość</button>
- </div>
- </form>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement