Thursday 9, February 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    Forum    |    About Us    |    Contact Us

Forms

Forms are the most fundamental method of interaction for your users. Users must use a form to enter information into a site. Think about it, every bulletin board, shopping cart, feedback form, and poll is a type of form. Without forms, the Web is nothing more than a publishing medium for those who can FTP Web pages up to a server.

 

GET & POST Methods:

There are two methods that you can use when creating a form in HTML. They are post and get, as in:

 

or:

 

If you don't specify a method, then the Web server assumes that you are using the get method. So what's the deal? They do the same thing right? Well, almost. You may have noticed that the URL looks a lot longer after you submit a form that uses the get method. For example, you may see something like:

http://studiesinn.com/form.php?name=fred&age=20&comments=This+site+rocks

That's because the get method puts the contents of the form right in the URL. There are a few disadvantages to this. First, depending on your Web server's operating system and software, there is a limit to how much data you can send through a form using the get method. On many systems, this limit is 256 characters. Also, the individual get queries may be stored in your Web server logs. If you are using space on a shared server, then other people may be able to decipher data sent from your forms that use the get method.

The post method was created to correct the inadequacies of the get method. The information sent using the post method is not visible in the URL, and form data cannot be deciphered by looking in the Web server logs. There also isn't such a small limit on the amount of data that can be sent from a form. Again, it depends on your server, but you probably won't ever hit the limit of sending data using the post method for a text-based form.

I use the post method for my scripts unless I need to debug something. When you need to debug something on a form, it is easy enough to switch to the get method (by changing the action line in your script) and then check the URL after you submit your buggy form. You can usually pick up typos and such with a quick look.

 

Example:

Name:
Age:

 

When you click the "Submit" button on the form the URL sent could look something like this:
http://www.studiesinn.com/display.php?name=adam&age=22

 

On display.php page you can retrieve the value by using the following code

 

Welcome .

You are years old!

 

The $_REQUEST Variable:
The PHP $_REQUEST variable can be used as the replacement of  $_GET, $_POST, and $_COOKIE. The $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.

 

 

Example:

Enter your name:
Enter your age:


 

When you click the Submit button on the form, following URL will be sent.

http://www.studiesinn.com/display.php

 

On display.php page you can retrieve the value as

 

Welcome .

You are years old!

 

 
     
   
PHP Tutorial
 
  Introduction
Introduction
  Variables
Variables
  Strings
Strings
  Operators
Operators
  If Else Statement
If Else Statement
  Loops
Loops
  Functions
Functions
  Forms
Forms
  Sessions
Sessions
  Cookies
Cookies
  Files
Files
  E-mail
E-mail
  Error Handling
Error Handling
  File Upload
File Upload
  PHP Databases
PHP Databases
  Connecting to a MySQL Database
Connecting to a MySQL Database
  MySQL Data Types
MySQL Data Types
  Inserting Data Into a Table
Inserting Data Into a Table
  Select Statement
Select Statement
  Where Clause
Where Clause
  Order By
Order By
  Update Statement
Update Statement
  Delete From Statement
Delete From Statement
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download Computational Modeling and Complexity Science  Ebook Computational Modeling and Complexity Science
   
Download Structure and Interpretation of Computer Programs  Ebook Structure and Interpretation of Computer Programs
   
Download Develop your own database software  Ebook Develop your own database software
   
Download Evaluating Java for Game Development  Ebook Evaluating Java for Game Development
   
Download Philip and Alex's Guide to Web Publishing  Ebook Philip and Alex's Guide to Web Publishing
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz