vBulletin

Thank you for visiting. This is our website archive. Please visit our main website by clicking the banner above.
vBulletin FAQ is dedicated to helping the forum owner build, manage and profit from his vBulletin Forum
vBulletin Web Hosting - Free skins and styles for your vBulletin - Search Engine Optimization




PHP Form input validation

mrasla
01-31-2006, 09:01 AM
I need to know how to parse a String in PHP in my form.
For example when a use enters his/her name, I want to check that the user only entered alphabetical characters. How do I add check for char?:confused:

thanks

VBW
02-01-2006, 02:31 PM
Most of the time numbers are not part of a name. But apostrophes, spaces, dashes, periods and commas might or can be.

PHP variable names must begin with "$" so this example may help, Try adding this to your form:for($i=0;$i<strlen($name);$i++)
{
if(($char[i]<'a' ||$char[i]>'z')&&($char[i]<'A' ||$char[i]>'Z'))
{
return FALSE;
}
return TRUE;
}With PHP you could also use a regular expression engine that would allow the above to be done without the loop.

mrasla
02-02-2006, 08:43 AM
thanks - it works fine, I just need to work on an error message to send back to user


vBulletin

seo book

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum