How To Allow Only Certain Amount Of Characters In A Web Form PHP HTML
Posted On Tue Jan 23, 2007 By hostman In PHP Forums And Topics Discussions About Hyper Text Programming Language Forums
suppose you have a web form, and you want to make sure that the user enters or submits atleast a certain amount of character before the form can be validated, lets say for example you have a contact us form and you want the user's name to have atleast 3 or more character in their name, if it has less, than the form will reject and tell the visitor to try again.
I have the same question, but the solution is simple, thanks for the support of the folks at www.webune.com i was able to get this question answer. I do all my web hosting with webune and I am very pleased with their service. The tech at webune said i can do this with PHP. Since i have all my hosting with them, php is standard in all their packages.
so the funtion to use in php to limit the least amount of character a user can enter is the strlen() function.
ok, to follow the contact us form example for the user's name, so once the user submits their name, i would use something like this to check the form to make sure the user's name in 3 or more character long otherwise, the form will fail, so this is the html i would use:
<!-- ##### BEGIN HTML CODE ##### -->
<form method="post" action="this_file.php">
<p>Name:
<input type="textfield" name="name">
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
<!-- ##### BEGIN HTML CODE ##### -->
<?
###### PHP CODE BEGIN #########
f(strlen($_POST[name]) > 3)
{
echo "Your Name is Valid";
}
else
{
echo "Sorry, Your name must contain atleast three characters;
}
###### PHP CODE END #########
?>
I have the same question, but the solution is simple, thanks for the support of the folks at www.webune.com i was able to get this question answer. I do all my web hosting with webune and I am very pleased with their service. The tech at webune said i can do this with PHP. Since i have all my hosting with them, php is standard in all their packages.
so the funtion to use in php to limit the least amount of character a user can enter is the strlen() function.
ok, to follow the contact us form example for the user's name, so once the user submits their name, i would use something like this to check the form to make sure the user's name in 3 or more character long otherwise, the form will fail, so this is the html i would use:
CODE:
<!-- ##### BEGIN HTML CODE ##### -->
<form method="post" action="this_file.php">
<p>Name:
<input type="textfield" name="name">
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
<!-- ##### BEGIN HTML CODE ##### -->
<?
###### PHP CODE BEGIN #########
f(strlen($_POST[name]) > 3)
{
echo "Your Name is Valid";
}
else
{
echo "Sorry, Your name must contain atleast three characters;
}
###### PHP CODE END #########
?>
Related Content
Information
Forums »
PHP Forums And Topics Discussions About Hyper Text Programming Language »
How To Allow Only Certain Amount Of Characters In A Web Form PHP HTML
PHP Forums And Topics Discussions About Hyper Text Programming Language »
How To Allow Only Certain Amount Of Characters In A Web Form PHP HTML
Title: How To Allow Only Certain Amount Of Characters In A Web Form PHP HTML
Description: How To Allow Only Certain Amount Of Characters In A Web Form PHP HTML
Tags: how ,to ,allow ,only ,certain ,amount ,of ,characters ,in ,a ,web ,form ,php ,html
Info: This Post Has Been Viewed 0 Times Since
Date: Tue Jan 23, 2007
Author hostman Received 0 Replies #1001
Date: Tue Jan 23, 2007
Author hostman Received 0 Replies #1001
Share
URL: 

Embed: 

To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE:: 

BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5