2

I have a kind of a guestbook on my page. It's just a common textarea like this:

echo '
<textarea name="msg"></textarea>';

and then I use a form to send me to the backend on submit:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$jinput = JFactory::getApplication()->input;
$msg = $jinput->getString('msg');
$columns = array('message');
$values = array($db->quote($msg);
$query->insert($db->quoteName('guestbook'))->columns($db->quoteName($columns))->values(implode(',', $values));
$db->setQuery($query);
$db->execute();

But my problem is, that if the user write something like:

Hey.

This is a nice site.

Bye for now!

The guestbook prints out:

Hey. This is a nice site. Bye for now!

How can I get the line breaks from the user-inputs?

EDIT: I echo the results like this:

$results = $db->loadObjectList();
foreach ($results as $row) {
echo $msg;
}
1
  • Does your data saved in manner which is you wanted to show ? Commented May 22, 2018 at 11:42

1 Answer 1

1

You don't show how you are echoing the result, but have you tried wrapping it in nl2br?

1
  • Just edited my question :) Don't know how to wrap it but I'll take a look :) Commented May 23, 2018 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.