what do i wanna ask?.....don't know what to call it :P

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

what do i wanna ask?.....don't know what to call it :P

Post by qads »

ok, i got a form which takes comments in a textarea and inserts into db, no problem there.

when it is inserted i use

Code: Select all

htmlentities($val);
to replace any "", ' etc.

when it needs to be shown on a page i use

Code: Select all

stripslashes($edit1їval]);
to remove the \

that works too, my problem is that it does't show as it was mean't to be, e.g.:

Code: Select all

text
text text text text
text text text
just like this forum.

wht can i use to make sure it shows as it was posted.

also can htmlentities(); stop users from useing java script in the posts?
cos i tried with <b> and it allowed that :?

i hope you understand what i am talking about cos i don't :roll:

thanks for your hlp in adv.
User avatar
PaTTeR
Forum Commoner
Posts: 56
Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:

Post by PaTTeR »

When your visitors fill the textarea, they use "RETURN" buton. In submitetd string you have a new line symbols.
Use function nl2br(), but before htmlspecialchars().
htmslspecialchars() convert special characters to HTML entities

Code: Select all

$variable = nl2br(htmlspecialchars($string));
Sorry, but my PHP is better than my English :wink:
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

thanks but that does't really help me with what i want it to do.
i want to be able to stop users from useing html and java in posts, also i want to show the posts as they were mean't to be , like this forum shows like i want it to.

will that do all that?
craginweb
Forum Newbie
Posts: 13
Joined: Fri Jul 05, 2002 12:49 am
Location: FWB Florida

Post by craginweb »

Post Reply