Hi friends, i need help please. I'd like to make such as guest book/feedback form that allow visitor to send comment. i make input form with HTML (Called input.html)and store data to add.p here is the code.
INPUT.HTML
<form method="post" action="add.php">
Enter Your comment here :
<p>
<textarea name="text" cols="30" rows="6"></textarea>
</p></form>
ADD.PHP
<?php
$haystack=$text;
$needle='.';
$maxchar=10;
$char=strlen($haystack);
if (($char <= $maxchar)&& (ereg(".",$haystack))) {
$text=substr($haystack,0,strpos($haystack,$needle)+1);
$db = WAP;
$connect = mysql_connect("localhost", "myuser","mypass");
$query = "SELECT * from mytable ";
$result = mysql_db_query($db, $query, $connect);
$num_rows = mysql_num_rows($result);
if(!$num_rows)
{
mysql_fetch_row($result);
MYSQL($db,"INSERT INTO mytable VALUES ('$text')");
header("Location:success.htm");
mysql_close();
}
else
{
header("Location:error.htm");
}
}
?>
I want to limit the input characters from users. So it will store to database mysql only chars<10 and ended with "." (dot).
Example someone input "test1." so it will store chars "test1."
The problem is when someone store chars like "test1.test2." it will store to database only "test1." and missing "test2."
How to solve that problem so it will store to database "test1.test2." ( I mean it will store first char to the end of ".")
Thanks for helping me.