Sign Up for OSTraining

Welcome, Guest
Username: Password: Remember me

TOPIC: What is the difference between the GET method and the REQUEST method

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46356

  • mhan
  • mhan's Avatar
  • OFFLINE
  • OSTarter
  • Posts: 9
  • Karma: 0
Can someone please explain to me what is the difference between the GET method and the REQUEST method? From what I have seen they seem to do the same thing.

Thanks for helping!

mhan
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46364

  • tessa
  • tessa's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3954
  • Thank you received: 134
  • Karma: 9
Hi Mhan,

GET retrieves variables from querystring or your URL

REQUEST merges GET and POST, where POST overrides GET. It's good to use REQUEST on self referential forms for validations.
Warm Regards,

Tessa Mero



Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46366

  • Nick
  • Nick's Avatar
  • OFFLINE
  • Administrator
  • Posts: 16855
  • Thank you received: 395
  • Karma: 57
Hi mhan,

There actually isn't a REQUEST method, but rather it's an array variable that contains the results/contents of GET and POST. So it can be used to "request" either GET or POST information.

Give our "Forms: Posting Data" for a good explanation (with examples) of the differences:
www.ostraining.com/courses/session/codin.../forms-posting-data/

Hope this helps!

Kind regards,
Nick
Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46368

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hi mhan,

This is confusing because the result of using them is often the same, but how they go about it and the level of security is different. In an oversimplified explanation, request includes three methods - GET, POST and COOKIE. GET and POST are more specific methods.

You can read more about the request variable here: php.net/manual/en/reserved.variables.request.php

The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character. www.w3schools.com/php/php_get.asp

GET and POST are typically used in form action fields. So you might also like to check out POST.
www.tutorialspoint.com/php/php_get_post.htm

Let us know if this clarifies things. It's a difficult topic for beginners, and I don't know your skill level, but I hope this points you in the right direction. If not ask some more question.

Cheers,
Ed
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46386

  • mhan
  • mhan's Avatar
  • OFFLINE
  • OSTarter
  • Posts: 9
  • Karma: 0
I am still confused but I know that as I use and program in php more I will gain the understanding I need.

I will eventually be teaching what I know to someone so I need to be able to clarify it for them when the time comes.

Thanks for all the help.

mhan
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46393

  • Nick
  • Nick's Avatar
  • OFFLINE
  • Administrator
  • Posts: 16855
  • Thank you received: 395
  • Karma: 57
Hi mhan,

Did you give the video I mentioned a try? It should hopefully help a lot.

Kind regards,
Nick
Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46400

  • thanh
  • thanh's Avatar
  • OFFLINE
  • Administrator
  • Posts: 32
  • Thank you received: 3
  • Karma: 1
For ex
<form action="index.php" method="[b]GET[/b]"> 
<input type="text" name="telephone" value="" />
....
</form>

When submit you can see parameter "telephone" in url and in PHP code you can use both GET and REQUEST to get value.
<form action="index.php" method="[b]POST[/b]"> 
<input type="text" name="telephone" value="" />
....
</form>

You don't see "telephone" in url because data is sent to server in HTTP data stream.
To get value in this case you have use REQUEST (or POST) to get value
REQUEST = both GET and POST
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46443

  • mhan
  • mhan's Avatar
  • OFFLINE
  • OSTarter
  • Posts: 9
  • Karma: 0
Nick,

Yes I watched the video. That is where the confusion comes from. In the video when the trainer used GET and REQUEST it looked like the same information in both the url as well as the browser window.

I know that the trainer said that REQUEST incorporates both GET and POST but I am still not getting it. Still looks the same to me.

Thanks for the help.

mhan
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46446

  • Nick
  • Nick's Avatar
  • OFFLINE
  • Administrator
  • Posts: 16855
  • Thank you received: 395
  • Karma: 57
Hi mhan,

Yes, that's because REQUEST is simply for "requesting" either GET's information or POST's information. That's basically all it does.

The above quality proves to be very useful because then you can change the "method" of the form as much as you want and not have to change the PHP script.

For example, let's say you're using the GET method in your HTML form and in your PHP script you're echoing:
$_GET['name']

if you change the method from GET to POST, then you also have to change the echo to:
$_POST['name']

However, if you were originally using REQUEST for the echo then you wouldn't have to change anything because the following would work for GET or POST methods:
$_REQUEST['name']

Give the above example a try within your code :)

Kind regards,
Nick
Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46559

  • mhan
  • mhan's Avatar
  • OFFLINE
  • OSTarter
  • Posts: 9
  • Karma: 0
Thanks Nick. I believe I understand it better now. I am beginning to see the difference.

mhan
Please become a member of OSTraining to reply to this post.

What is the difference between the GET method and the REQUEST method 1 year 1 week ago #46561

  • Nick
  • Nick's Avatar
  • OFFLINE
  • Administrator
  • Posts: 16855
  • Thank you received: 395
  • Karma: 57
You're welcome, mhan! We're all glad to be of help! :)

With coding, generally the more you do it, the better you understand it. For that reason, be sure to practice, practice, practice.

Kind regards,
Nick
Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

Sign Up for OSTraining

Powered by Kunena Forum

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.