OK first of all I am very new to PHP. I think some of you might know that already, but two weeks in now and I am starting to get some idea of what to do with a little (very little) PHP.
OK here is a simple form I created:
form.php
<HTML>
<HEAD>
<TITLE></TITLE>
<BODY>
<FORM action="formdisplay.php" method="POST">
Username: <INPUT type="text" name="userName" size="20" maxlength="20">
Age: <INPUT type="text" name="userAge" size="3" maxlength="3">
<INPUT type="submit">
</BODY>
</HEAD>
</HTML>
This is the PHP script:
formdisplay.php
<?PHP
if ($_POST['userName']['userAge'] == null)
{
echo("Please enter Your name");
}
elseif ($_POST['userAge'] == null)
{
echo ('Please enter your age');
}
else
{
echo "Hello ".$_POST['userName']." "."you are ".$_POST['userAge']." years old";
}
?>
I know what your going to say. I could have written this script a lot better (better use of PHP functions, arrays, less code etc...). But with that said it does work and I do get an idea of "how it works" etc... will get better with time and effort.
Now for what I want to know (beating round the bush...I know)
How can I stop users from entering numbers in the 'userName' field and not using Characters in the 'userAge' field?
Any help would be very helpful. I am not sure what to look for in the PHP Manual that will answer this question.
Oh but if you do want to show me how I would put something like this together better then please do not hesitate to show me.
Kindest regards,