Web Shoppe
Home | Coding | PHP | Variables in a Form

Variables in a Form

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.
The form will pass the variables on to the PHP page, where they will be displayed as the text the user entered. Try it out:

Your name: 
Your age:
 
 

about this site
site map
forums
ask a question
link this site

html tutorials
css tutorials
php tutorials
javascript tutorials
htaccess tutorials

graphics design
graphics tutorials
website design
internet copyright

about domains
about web hosting
hosting tutorial
xentrik hosting
ftp tutorials

stats logger
search engines
code generators
button labeller
remote services

font archive
website layouts
website graphics
useful scripts