Tutorial: PHP
GET And POST
 

As most of you already know, these two are used for form processing method. For example, you may see their usage like;

<form method=”get” action=”page.php”>
or
<form method=”post” action=”page.php”>

 

GET and POST
 
Get Method

- When you use get method, the submitted data will be passed to another page by encoding them into a URL. Taken from the HTML 4.0 specification quotation;

  • If the method is “get” – -, the user agent takes the value of action, appends a ? to it, then appends the form data set, encoded using the application/x-www-form-urlencoded content type. The user agent then traverses the link to this URI. In this scenario, form data are restricted to ASCII codes.

 

- Meaning, when the form is submitted, the URL of the page where you’re passing the data to will appended with all the data.

 

- OK. In the previous example, we’re passing the form to a page called page.php. So, our URL will be something like;

http://website.com/
page.php?data1=blabla&data2=blalabla

 

- So when you want retrieve those data from the page.php, you must use the $_GET method. For example if you want to retrieve data2 value;

$variable2 = $_GET['data2'];

 

- Using get method limits the length of data that can be sent. It’s also not a good practice especially when sensitive data like password are being passed. But in certain cases, it’ll make it easier for bookmarking purpose.

 

GET and POST
 
Post Method

- When you use post method, the submitted data will be passed to another page “behind the scene” by putting them in standard input. Taken from the HTML 4.0 specification quotation;

  • If the method is “post” –, the user agent conducts an HTTP post transaction using the value of the action attribute and a message created according to the content type specified by the enctype attribute.

 

- This means cleaner adress bar, lol. So, if you want to retrieve the submitted data from the page.php, you must use the $_POST method. For example if you want to retrieve data1 value;

$variable1 = $_POST['data1'];

 

- Using post method is a good practice for a secure data passing. Plus, more data can be passed ;) The disadvantages is of course, the page can’t be bookmark.


 

 

 


 

Avarage Rating:  from 3 votes.
 
Rate This Page;

 

 

Comment? »

 

 

Leave a comment
 

 Name (required)

 E-mail (required,not published)

 URI

 

 

 

 
 

Advertisements
 
Must clicks!

lady
 
ajwa . Naj . Wawa . 26 . . 290 days until my 27th birthday on May 18th . IT Engineer . Malaysian . Dreamer . Worrier . Simple . Boringgg . but Laughs a lot . Gaining back her self-confidence ♥ Mariah carey . David Archuleta . Michael Bublé . James Morrison . Anuar Zain . Akim . Faizal Tahir . Diddy . Jesse McCartney . Linkin Park . BSB . *N Sync . Rascal Flatts . Smallville . Charmed . One Tree Hill . Merlin . Summerland . The City . Jonas . Matrix Trilogy . LOTR . Star Wars Saga . Twilight Saga . The Covenant . Taylor Lautner . Tom Welling . Paul Walker . Steven Strait . Hugh Jackman . Josh Hartnett . Chad Michael Murray . Ewan McGregor . Natalie Portman . Cameron Diaz

?

playlist cam cam
 
facebook twitter yahoo! messenger youtube

 
Your Text Ads Here?
 

 

navigate
 
Journal
Lady
Artwork
Collective
Visitor
        Graphics
        Downloads
        Scripts
        Reads
        Games
        Interactive
        Tutorial
 
Plugboard
Exits
SecretWhisper

 

skins





skins more?

 

stats
 
7 online currently,
0 cried on this page,
342383 were all cried out,
Since 29-Jan-2006

Powered by  MyPagerank.Net

 

random links
 
Kematz
Ayu The Sun
Syamelia * Guilty Indulgence
Lagi-lagi Filem
Mapple Berry
Aqua * Lost With No Direction
Adie Waridi
LiLo
Tira Blurb
The Sweet Escape of Lyn Yusoff
Joe Klubbkidd
PaanMFR
Wenkt.com
Haelios
MyImperfections.org
RedMummy.com
Sutramaya.com
Sky-Reflection.com
Oh-Doll.net
ItsNerdy.org

link exchanges more?

 

Follow Me


 

etcetera

 

 
Earn Money Online?
Free Domain?
 

 
 Search the web/site.
Web SawYouCry

 

 

© Najwa 2005-08
SecretWhisper Production
All rights reserved.
* * * * * * * * * * * * *