Jump to content

validating textarea


mrjameer

Recommended Posts

The main issue is to protect the database entrys so i advise to use the following.

addslasshes
trim

Also you can use all these from the link as i have provided.

http://uk2.php.net/addslashes


if both the examples below if the users has a < or > there be an error message.

good luck hope you understand all the best redarrow.

example1 for eregi.
[code]
<?php

$mes="hi there i am redarrow";

$ban=array('<','>');

foreach($ban as $x){


if(eregi($x,$mes)){


echo " bad word please try agin";
exit;

}
}
echo "good words congratulations";

?>
[/code]


heres a quick form example

[code]
<?php

if($_POST['submit']){

$ban=array('<','>');

foreach($ban as $x){


if(eregi($x,$mes)){


echo " bad word please try agin";
exit;

}
}
echo "good words congratulations";
}
?>

<form method="POST" action"">
<br>
please tell me what you think
of my site!
<br>
<input type="text" name="mes">
<br>
<br>
<input type="submit" name="submit" value="valadate words">
<br>
</form>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/25280-validating-textarea/#findComment-115266
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.