Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7748261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:44:18+00:00 2026-06-01T10:44:18+00:00

please i am trying to make the message show on newline as the customer

  • 0

please i am trying to make the message show on newline as the customer types it, but i am getting /r/n between each line and also trying to make the $body .= $_SESSION['username']; appear on a separate line i have tried to use this example to solve but has not been successful the code is below

   <?php require_once("include/session.php");?>
<?php require_once("include/dataconnect.php");?>
<?php require_once("include/functions.php");?>
<?php include("include/mheader.php");?>

<?php
$submit = $_POST['Notify'];
$message = mysql_real_escape_string(htmlentities(strip_tags($_POST['message'])));
//echo "$message";
//die();
if('POST' === $_SERVER['REQUEST_METHOD']) 
{
if (isset($message)) 
{
//Get Email Address
    $emails = mysql_query("SELECT email FROM reusers WHERE username = '{$_SESSION['username']}'")or die(mysql_error());
    //$emails = mysql_query("SELECT reusers.email FROM reusers INNER JOIN repplac ON reusers.username = repplac.Uname AND reusers.username = '".$_SESSION['username']."'")or die(mysql_error());
    $results = (mysql_fetch_assoc($emails)) or die(mysql_error());
    $email= $results['email'];
    //echo "$email";
    //die();
     if(mysql_num_rows($emails) == 0){
         exit("No email addresses found for user '{$_SESSION['username']}'");
    }
    $email = mysql_result($emails, 0);
    //echo "$email";
    //die();
$body = $_SESSION['username']. "<br>"
         . nl2br($_POST['message']);
    $to = $email;
   $subject = "copy of your notification"; 
$headers = "From: noti@r.co.uk\r\n";  
$headers  .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Bcc:noti@r.co.uk' . "\r\n";
mail($to,$subject,$body,$headers);
    }
    }  
?>
<p>
<form action='notification.php' method='Post' class='rl'>
    <div>
    <label for='message' class='fixedwidth'>Message</label>
    <textarea name="message" rows ="7" cols="40" id="message"></textarea>
    </div>

    <div class='buttonarea'>
            <p>
            <input type='submit' name='notify' value='Notify'>
            </p>
            </div>
            </form>
            </p>

<?php include("include/footer.php");?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:44:20+00:00Added an answer on June 1, 2026 at 10:44 am

    Since it’s generally safer to send HTML emails in a more archaic form of HTML I’m going to allow the HTML email content to be HTML 4; so it doesn’t need to be XML well formed and nl2br() is acceptable.

    You’re specifying that the content of your email is HTML so normal line endings, \r, \n and \r\n are pretty much irrelevant.

    Try something like:

    $body = $_SESSION['username']. "<br>"
             . nl2br($_POST['message']);
    

    There’s no sanity checks or validation in there but I think that’s what you’re trying to get it to do.

    —- EXAMPLE CODE —-

    I’ve just refactored your code somewhat so I could better see what you’re doing (it’s just a matter of personal preference) and put comments in to show what I’m getting at with regards to sanity checks and validation.

    I’ve not tested any of this, it’s pretty much just an example using your code.

    <?php
    require_once "include/session.php";
    require_once "include/dataconnect.php";
    require_once "include/functions.php";
    require_once "include/mheader.php";
    
    //sanity checks - ensure the form has been posted and that there IS a message
    if($_POST && !empty($_POST['message'])) {
    
      //sanity check - ensure there IS a username
      $sUsername = !empty($_SESSION['username']) ? $_SESSION['username'] : "";
      if($sUsername) {
    
        //check the username against the database?
        $resultEmail = mysql_query("SELECT `email` FROM `reusers` WHERE `username` = '{$sUsername}' LIMIT 0, 1")
                or die(mysql_error());
    
        //no result - could throw an Exception here
        if(mysql_num_rows($resultEmail) == 0) {
          die("No email addresses found for user '{$sUsername}'");
        }
    
        //email verified against the database
        else {
          $sEmail = mysql_result($resultEmail, 0);
    
          //create the email
          $headers = "From: noti@r.co.uk\r\n"
                . 'MIME-Version: 1.0' . "\r\n"
                . 'Content-type: text/html; charset=iso-8859-1' . "\r\n"
                . 'Bcc:noti@r.co.uk' . "\r\n";
    
          $to = $sEmail; //assuming the email address retrieved from the database has already been mxrr checked etc...
          $subject = "copy of your notification"; 
    
          $body = $sUsername . "<br>"
    
                 //remove slashes as this is going in an email, strip tags and convert newlines to "<br>"
                 // since you're using iso-8859-1 there shouldn't be any oddities unless someone completes
                 // the form using an Arabic character set (for instance)
                . nl2br(strip_tags(stripslashes($_POST['message'])));
    
          //send the email
          if(!mail($to, $subject, $body, $headers)) {
            die("sendmail error!");
          }
        }
      }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make ioquake3 on IBM machine. But, I kept getting the
I was trying to make weather based PHP script to show weather related data.But,I'm
Please stop me before I make a big mistake :) - I'm trying to
Please I am trying to create an Oracle database in Rational Rose but the
I am trying to make a simple Client-Server application but when I execute the
Hello i am trying to make function with while loop in php but cant
I'm trying to make it so messages are displayed like this *Old Message Sooner
I am trying to make my UITableView Editable but I'm having some trouble with
I need a little help here please.What am trying to do is pull all
Please understand that I am not trying to start a flame war. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.