Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Formularz kontaktowy
Sofokles
post 7.07.2017, 13:28:03
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 7.07.2017

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


Witam,

Po napisaniu wiadomości typu:

Cytat
Tekst
Tekst
Tekst


Otrzymuję ją w skrzynce w takiej postaci:

Cytat
Tekst Tekst Tekst


Zamiast nowej linii robią mi się spacje.

Mógłby mi ktoś przerobić ten kod żeby wysłane wiadomości przychodziły takie jakie zostały wysłane w formularzu?

Dziękuję

Kod
<?php
/*
Credits: Bit Repository
URL: http://www.bitrepository.com/
*/

include dirname(dirname(__FILE__)).'/config.php';

error_reporting (E_ALL ^ E_NOTICE);

$post = (!empty($_POST)) ? true : false;

if($post)
{
include 'functions.php';

$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);


$error = '';

// Check name

if(!$name)
{
$error .= 'Please enter your name.<br />';
}

// Check email

if(!$email)
{
$error .= 'Please enter an e-mail address.<br />';
}

if($email && !ValidateEmail($email))
{
$error .= 'Please enter a valid e-mail address.<br />';
}

// Check message (length)

if(!$message || strlen($message) < 15)
{
$error .= "Please enter your message. It should have at least 15 characters.<br />";
}


if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
     "From: ".$name." <".$email.">\r\n"
    ."Reply-To: ".$email."\r\n"
    ."X-Mailer: PHP/" . phpversion());


if($mail)
{
echo 'OK';
}

}
else
{
echo '<div class="notification_error">'.$error.'</div>';
}

}
?>


Ten post edytował Sofokles 7.07.2017, 13:29:52
Go to the top of the page
+Quote Post
Pyton_000
post 7.07.2017, 13:40:29
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


http://devdocs.io/php/function.nl2br
Go to the top of the page
+Quote Post
Sofokles
post 7.07.2017, 14:04:16
Post #3





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 7.07.2017

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


Co i gdzie mam wstawić?
Go to the top of the page
+Quote Post
Puszy
post 7.07.2017, 14:26:33
Post #4





Grupa: Zarejestrowani
Postów: 279
Pomógł: 42
Dołączył: 10.10.2011

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


Używaj BBCode
  1. $mail = mail(WEBMASTER_EMAIL, $subject, nl2br($message),
  2. "From: ".$name." <".$email.">\r\n"
  3. ."Reply-To: ".$email."\r\n"
  4. ."X-Mailer: PHP/" . phpversion());
Go to the top of the page
+Quote Post
Sofokles
post 7.07.2017, 14:32:01
Post #5





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 7.07.2017

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


Przepraszam, następnym razem będę pamiętał.

Dziękuję serdecznie za pomoc! Wszystko działa smile.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 6.07.2025 - 11:54