Break lines in PHP are not working

html, php

Solution

You should try with `<br/>` HTML tags because you have specified `text/html` content type:

$message = "Name: $name<br/>
            Email: $email<br/><br/>
            Message: $message";

Problem

I am trying to formate the email using line breaks, so it looks like: ``` Name: Email: Message: ``` I added the `\r\n` but it did nothing, then I tried and added `$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";` thinking that I need to tell it that this is HTML and that did nothing as well. What I am doing wrong? ``` <?php session_start(); if ($_SERVER['REQUEST_METHOD'] == 'POST'){ ob_start(); if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['message']) && isset($_POST['token'])){ if($_SESSION['token'] != $_POST['token']){ $response = "0"; } else { $_SESSION['token'] = ""; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $to = "support@loaidesign.co.uk"; $subject = "New Message From: $name"; $message = "Name: $name\r\n Email: $email\r\n\r\n Message: $message"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'From: '.$email . "\r\n"; $mailed = ( mail($to, $subject, $message, $headers) ); if( isset($_POST['ajax']))$response = ($mailed) ? "1" : "0"; else $response = ($mailed) ? "<h2>Success!</h2>" : "<h2>Error! There was a problem with sending.</h2>"; echo $response; } } else { echo "Form data error!"; } ob_flush(); die(); } ?> ```

Original source