I will tell you first why you want to use variable and then you will understand what is a variable.
Lets suppose I have a database where I keep my registered user's name.
In php I will have a script to insert the name in the db, something like this.
INSERT INTO mymembers (firstname
) VALUES ('John');
Now everytime I run the script I have an entry with the firstname John, unfortunately my members are not all John, so I need a way to vary the names, you got it variables.
How do I do that?
Well, with php it's very easy, first my members will register with a form on a website, in the form I have a field like that.
First Name: <input type="text" name="fname" size="20">
This will give you the typical form field that you see usually.
What is interesting though is the name "fname" will now be use by the php engine as a variable, which mean whatever you will write down in the box, will be retain in the variable named "fname".
So to get back to my example of the insert in the db now I will have this;
INSERT INTO mymembers (firstname
) VALUES ('$fname');
The dollar sign tell php this is a variable.
So if you typed in the box Robert then it would be the same as if I had wrote the insert manually as
INSERT INTO mymembers (firstname
) VALUES ('Robert');
And the next user will write something different but for my script it doesn't matters because I'm using a variable.
Hope this help.
Gamebits