Help With Some Multi Lined Input!

I Have Some Input That Is Not Displaying Newlines

Page 1 of 1

3 Replies - 919 Views - Last Post: 08 January 2007 - 10:21 AM

#1 Addiction2Code  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 19-December 06

Help With Some Multi Lined Input!

Posted 08 January 2007 - 09:43 AM

I Have A Messenger On My Website And People Are Complaining That When They Send A Message Ex.
1
2
3
The Other Person Views It As 1 2 3 Without The Newlines
The Post Code Is Below!
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/master.css">
</head>
<body>
<h2>Send Message</h2>
<form action="send.php" method="post" enctype="text">
<label for="text"><h3>To:</label>
<input type="text" name="to" id="to" />
<label for="text"><h3>Subject:</label>
<input type="text" name="subject" id="subject" /> 
<label for="text"><h3>Message:</label>
<TEXTAREA TYPE="TEXT", NAME="message", style="height:300px; width:400px;" ></TEXTAREA>
<input type="submit" name="submit" value="Submit" /></h3>
</form>




Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Help With Some Multi Lined Input!

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Help With Some Multi Lined Input!

Posted 08 January 2007 - 09:55 AM

The code above is simply the form...not the code that processes the text. Can you post the code from send.php? there is likely a breakdown betwen what is being interpreted as a new line between \n and <br>.
Was This Post Helpful? 0
  • +
  • -

#3 Addiction2Code  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 19-December 06

Re: Help With Some Multi Lined Input!

Posted 08 January 2007 - 10:01 AM

View PostAmadeus, on 8 Jan, 2007 - 09:55 AM, said:

The code above is simply the form...not the code that processes the text. Can you post the code from send.php? there is likely a breakdown betwen what is being interpreted as a new line between \n and <br>.


THE CODE For send.php
<?php
require 'userinfo.php';

require 'MESN.php';

echo '<hr />';

if($logged_in == 1) {

$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
mysql_query("insert into messages
(viewers, subject, sender, message) values
(\"$to\",\"$subject\",\"$username\",\"$message\")") or die(mysql_error());
echo('<h3>' . $username . " Your Message Was Sent!</h3>");
echo('The Following Message Was Sent To ' . $to . '<br />' . $_POST['message']);
echo('</body>');
echo('</html>');
} else {
echo('<head><link rel="stylesheet" type="text/css" href="../css/master.css"></head>');
echo('<h3>You Must Be Logged In To Access This Page!</h3>');
echo('</body>');
echo('</html>');
}
?>




AND HERE IS THE CODE FOR THE VIEWER read.php
<?php
require 'userinfo.php';

require 'MESN.php';

echo '<hr />';

if($logged_in == 1) 
{
$MTM = mysql_query("SELECT * FROM messages " . "WHERE viewers=" . "'" . $username . "'" . " OR viewers='everyone'");
echo('<h2>Your Madtast Messages!</h2>');
echo "<hr />";
while($row = mysql_fetch_array($MTM))
  {
	echo('<table border="1" width="600" height="200"><tbody><tr><td>');
  echo ("<h3>" . "Sender: " . $row['sender'] . "<br />" . "Subject: " . $row['subject'] . "<br />" . "" . $row['message'] . "</h3>");
  echo("</td></tr></tbody></table><hr />");
  }
 
echo "<hr />";
mysql_close($con);
}
else { echo("<h2>You Must Be Logged In To Access This Page!</h2>"); }
echo('</body>
<html>');
?>


Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Help With Some Multi Lined Input!

Posted 08 January 2007 - 10:21 AM

Try something like:
while($row = mysql_fetch_array($MTM))
  {
   $message = str_replace("\n","<br>",$row['message']);
	echo('<table border="1" width="600" height="200"><tbody><tr><td>');
  echo ("<h3>" . "Sender: " . $row['sender'] . "<br />" . "Subject: " . $row['subject'] . "<br />" . "" . $message . "</h3>");
  echo("</td></tr></tbody></table><hr />");
  }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1