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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.