First you make a regular
HTML form page, like we
learnt here:
<form
action="form.php"
method="post">
Your name:
<input
type="text"
name="name"><br>
Your age:
<input
type="text"
name="age"><br>
<input
type="submit">
</form> |
|
This form consists of two
text boxes, one which is
called "name" and another
which is called "age". These
names are our variables. We
save this file as "form.html",
but notice on the first line
how the form points to a
file called "form.php"?
Well, that is a seperate
file, consisting of this PHP
code:
Hi <?php
print $name;
?>.
You are <?php
print $age;
?> years
old. |
|
Other Basics
Other basics include if
statments:
if ($x==1) {
// if x
equals 1
then run
this :o
} |
|
and while:
while
($x==1) {
// while x
is still
equal to 1 ,
run!
} |
|
Will run forever - as $x is
always 1!
One more for now, for:
for ($i=0;$i<100;$i++)
{
print "We
are $i<br>";
} |
|
Will print "We are " then
the nth time its dont it
(minus 1 cus it starts from
0) like:
We are 0
We are 1
We are 2
...
We are
99 |
|
|