Problem with string

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Problem with string

Post by Monopoly »

There is a problem with my guestbook:

when I type in the textarea the following string:
s
s
s
s
s
(breaking lines pressing ENTER)
I get the following output on the mainpage : s s s s s s

What should I do ? I guess I didn't add enough code ))

Thank you
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Problem with string

Post by califdon »

I think the first thing you should do is explain why you think we can tell you what's wrong with code that we have never seen.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Problem with string

Post by Ambush Commander »

use nl2br(htmlspecialchars($text)). Newlines in text don't translate to newlines in HTML, and chances are you've got an XSS vulnerability.
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Re: Problem with string

Post by Monopoly »

thnx Ambush Commander, it worked !
Post Reply