|
CGI - Validation |
tutorial by Matt |
Validation is a very easy thing to do but can sometimes be
very tricky. These last two sections will be very short because they are
fairly easy and i'm sure you would like to finish off with powerful but
easy stuff.
Validation is usually done through an If Conditional Statement
An example of an if conditional statement is listed below:
if ($query->param('uname') eq 'CGIHaven') {
do something in here.
}
There are also two other parts to an If Conditional Statement.
These are the elsif and else statements.
Listing 6.1 -- elsif conditional
-----------------------------------
if ($query->param('uname') eq 'CGIHaven') {
do something in here.
}
elsif ($query->param('uname') eq 'CGIRules') {
Do something else here.
}
Listing 6.2 -- else conditional
-----------------------------------
if ($query->param('uname') eq 'CGIHaven') {
Do something in here.
}
elsif ($query->param('uname') eq 'CGIRules') {
Do something else here.
}
else {
Do Something else.
}
Now there is a strange symbol in the if and elsif conditionals.
This strange symbol is the eq. You are
probably wondering what this means. This symbol means equals.
You can find a listing of the string equality operators below
Listing 6.3 -- String Equality Operators
----------------------------------------------------------
eq
ne
That is how easy validation is. This was a very VERY short
section but it didn't need to be long because it was so simple.
Go on the last section Regular Expressions
|
|
|
|