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
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

PHP Topics
Introduction
Syntax
Data Types
Variables
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




REQUEST Method in PHP


Topic

How to use REQUEST method in PHP to get form values?



Explanation

This is a 'superglobal', or automatic global variable. $_REQUEST is an associative array consisting of the contents of $_GET, $_POST, and $_COOKIE ie, it is available in all scopes throughout a script.

Example:  Create a simple form which contains variables handled by GET,POST method and COOKIE variable.

A Simple Form:
Name:

Email:


When the user fill the form and click submit button the form will be submitted to request.php.

Coding to create a simple form
<?php
setcookie("user", "Alex");
foreach($_REQUEST as $val)
{
echo"$val";
echo"<br>";
}
?>
<form action="request.php?age='25'&city='cbe'" method="POST">
Name: <input type="text" name="name">
Email: <input type="text" name="mail">
<input type="submit" value="Submit">
</form>

In the above code form filed variable such as "name" and "mail" is handled by POST method as we mentioned method=POST. Variables such as "age" and "city" are passed through url so it will be accessed only by GET method and here cookie is set for variable "user " with value "Alex" by using setcookie function. Save above code with the name getvariable.php.

When the user enter the values for name and email and clicks the submit button, variables with the values are submitted to request.php. Here variables handled by different methods are printed. Thus $_REQUEST variable is an associative array used to get the values of POST,GET and COOKIE variables.

RESULT





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