ereg not behaving as expected
Posted: Tue Mar 27, 2007 4:31 pm
feyd | Please use
but it seems to act like
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm having a problem with the ereg function to verify a user submitted variable
the situation is that the user is submitting a textarea post variable
there are a number of allowed characters
there are more in the actual application but i have removed to demonstrate the problem as removing them makes no difference
the php code is as followsCode: Select all
$message=$_POST['textarea1'];
if (ereg("^[A-Za-z0-9\n]*$",$message)) {
$textValid=TRUE;
} else {
echo "error";
}Code: Select all
$message=$_POST['textarea1'];
if (ereg("^[A-Za-z0-9]*$",$message)) {
$textValid=TRUE;
} else {
echo "error";
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]