H I O X INDIA
FREE PHP Topics
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

PHP Topics
Introduction
Common Header
Random Number
Type
Form Variables
Date and Time
File Handling
Error Handling
DB Size
PHP Mail
String Tokens
Running PHP from JS
Array To JS
Array to PHP
Encryption
Ask Your Doubts
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




others


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