Results 1 to 3 of 3
Thread: Acessing Form Variables
Jun 1, 2003, 14:43 #1
Acessing Form Variables
I thought I'd start here by posting a few tutorials from my site on various subjects....here is my first one!
When a user submits a form on your website, you want to be able to collect the data in your PHP script, then usually process it. This can be done very easily using a number of built in methods, but which method should you use? This all depends on the version of PHP you have.
You should know that you know something is a variable because it has the dollar $ sign prefixing the name. For example, a variable named date would be written as $date.
When you submit a form to your processing page, the data in sent from the form to that page. If you don't collect it, then it will just be lost - a very useless submission form that will be!
Depending on your PHP version and setup, there are 3 ways of accessing the submitted data. For example, if we had a form that submitted the user's e-mail address (from a field called email), we could access that data by using on of the following:
$email // Short style
$_POST['email'] // Medium style
$HTTP_POST_VARS['email'] // Long style
The medium style works with PHP 4.1.0+ and is relatively easy to use. But it will not work on previous versions.
The long style is the one that I use when writing my scripts, and the one that the Olate website uses. This is guaranteed to work on every setup and server but has been depreciated and could be removed from any new release of PHP, and is likely to be.
This basically shows you how you can retrieve data from a submitted form. It is completely up to you which style you use.
Jun 1, 2003, 14:45 #2
- Join Date
- Mar 2001
- Philadelphia, US
- 0 Post(s)
- 0 Thread(s)
Jun 1, 2003, 14:51 #3
Thanks for the comment....You think it is better to use the 'medium style'?