I'm sending a test email to myself which contain values inserted into a form.
I recieve the email, but the "formating" is all wierd and \r\n
is visible. I tried %0D%0A
and </br>
(although didn't specify that it would be an HTML) as well and it was also visible. I also tried PHP_EOL
.
Additionally, I also recieve a 2cnd email right after the 1st one, but it contains only a fraction of the previous form.
1st email:
Date of arrival: 19-02-2021%0D%0A
Date of departure: 27-02-2021%0D%0A
Room selected: Room 01 %0D%0A
Name: dread%0D%0A
Surname: Zxy%0D%0A
Email myemail@gmail.com%0D%0A
Phone number: 012345678
2cnd email:
Date of arrival: 19-02-2021%0D%0A
Date of departure: 26-02-2021%0D%0A
Edit I just noticed that the 2cnd email does not contain the same date of departure as the 1st one. I have no idea why that is, so I'll add the jQuery code as well.
I would be greatful if anyone has any idea how to resolve this.
The code:
<?php
if(isset($_POST['submit'])) {
$arrivalDate = $_POST['arrivalDate'];
$departureDate = $_POST['departureDate'];
$room = $_POST['room'];
$user_name = $_POST['user_name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$to = $_POST['email'];
$subject = 'Reservation';
$body = 'Date of arrival: '.$arrivalDate.'\r\n
Date of departure: '.$departureDate.'\r\n
Room selected: '.$room.'\r\n
Name: '.$user_name.'\r\n
Surname: '.$surname.'\r\n
Email '.$email.'\r\n
Phone number: '.$tel;
wp_mail( $to, $subject, $body );
echo "Sent!";
}
?>
jQuery(document).ready(function($) {
$("#arrivalDate").datepicker({
minDate: 'dateToday',
dateFormat: 'dd-mm-yy',
onSelect: function (date) {
$("#departureDate").datepicker('option', 'minDate', date);
}
});
$("#departureDate").datepicker({
dateFormat: 'dd-mm-yy'
});
});