I'm new for PHP,could someone help me?

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
kaily
Forum Newbie
Posts: 12
Joined: Fri Jul 05, 2002 12:17 pm

I'm new for PHP,could someone help me?

Post by kaily »

How to get what the user has post?
I want to know if the user has POST a invalid character(e.g "<","|").
Please tell me what I should do!
Sorry for my english!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to check out the preg_match() function - it'll let you use regular expressions to look for things in the posted data.

Mac
LenHewitt
Forum Newbie
Posts: 10
Joined: Sat Jul 06, 2002 6:13 am
Location: United Kingdom

Post by LenHewitt »

You can clean user input by using a function such as:

function clean($input, $maxlength)
{
$input = substr($input, 0, $maxlength);
$input = EscapeShellCmd($input);
$input = htmlspecialchars(input);
return ($input);
}

If you wish the meaning of HTML characters to be preserved you should use htmlentities() rather than htmlspecialchars()
Post Reply