H I O X INDIA
FREE PHP Topics
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Templates 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)
Español Français 中文 Deutsch Portuguese Japanese தமிழ்
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

PHP Topics
Introduction
Syntax
Data Types
Operators
Control Structures
Functions
Pre-defined Function
Calendar Functions
Date and Time
Array Functions
Array Functions List1
Array Functions List2
Math Functions
PHP Mysql Functions
File Handling
Error Handling
DB Size
PHP Mail
String Tokens
String Functions
String Functions List1
String Functions List2
Session Functions
Cookies Functions
Form Variables
Running PHP from JS
Array To JS
Array to PHP
Encryption
Common Header
Ask Your Doubts
More about PHP
Feedback





Form Variables in PHP


Topic

How to get values of variables from outside PHP?



Explanation

Consider a simple form which contains a username, email address and a submit button.

A Simple Form:
Name:

Email:


When the user fill the form and click submit button the form will be submitted. When a form is submitted to a PHP script, the information from that form is automatically made available to script mentioned in form action part.

Coding to create a simple form

<form action="variable.php" method="post">
Name: <input type="text" name="name">
Email: <input type="text" name="mail">
<input type="submit" value="Submit">
</form>

Here when submit button is clicked, the form data will be send to variable.php file because this is the file name mentioned in the form action part. If u want to submit form data to the same page then you have to mention either action="$PHP_SELF" or action="".

<form method="post" action="<php echo $PHP_SELF; ?>">
</form>

When any other file name is specified in the action part then the form data will be available to that file. By this we mean that the form data will be made available to the same file in which form is present or to any other file by specifying the file name in action part.

There are two ways to access the form variables, They are POST and GET method.In the above code we have used POST method to the get the form data.

Form is submitted when the user clicks the "Submit" button, when POST method is used the URL will not contain any form data, the URL will be passed as such. Here URL will be

http://www.hscripts.com/tutorials/php/variable.php

When GET method is used then the form data is passed through the URL ie, URL will contain form data.

http://www.hscripts.com/tutorials/php/variable.php?name=admin&mail=ad@hiox.com

There are many ways to access data from your HTML forms. Some examples are listed below.

HTTP POST variables: $_POST

HTTP GET variables: $_GET

HTTP File upload variables: $_FILES

Request variables: $_REQUEST






privacypolicy     licence     sitemap
(c) copyright, 2004 hioxindia.com