SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $REQUEST method- how to use it?

    hello there,

    actually i want to send brand_id to next page,
    so i am using
    PHP Code:
    $brand_id=$REQUEST['brand_id'
    but i am not getting how can i set value for brand_id on previous page.
    bit confused..
    in details what i am trying to do is,

    1)adding data in my table prod(prod_id,prod_name, brand_id)
    so here, i don't want to add brand_id, manually,
    so am i going right way? or some other method is there?

    please help me.

  2. #2
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $REQUEST combines $_POST, $_GET etc., it's not another way to pass information.

    And stop using something like $brand_id=$REQUEST['brand_id'] when you can just as well keep using $REQUEST['brand_id']. It's totally pointless.

  3. #3
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then please give me some suggestion,

    means i was using logic like, when we logged in, a userid which we used is passed throughout the next pages .

    so how it work, give me some hint.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    it is $_REQUEST
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Member worker's Avatar
    Join Date
    Dec 2007
    Location
    Pakistan
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All it could be done through sessions
    if you have an idea about session
    because session basically works for sending user id from page to page.

  6. #6
    SitePoint Zealot zalucius's Avatar
    Join Date
    Jul 2007
    Location
    Denmark
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sessions are good for data you want to access on multiple pages, aslong as the visitor is on your site. (user_id, shop_basket etc..)
    $_SESSION
    Problem with sessions, is that you have to store the data in it, before you can use it... it wont work as a temporary placeholder like $_GET.

    QueryStrings are good for accessing various items, when the page loads... like read a specfic article, or perform a defined task (www.somesite.com?article_id=2 or www.somesite.com?action=add_new etc)
    $_GET

    Form data is used for user interactivity. Such as login, posting on a forum etc... $_POST

    the $_POST and $_GET arrays can both be accessed using the $_REQUEST array.
    But I must admit that I always prefer the $_POST and $_GET... It helps to understand excatly where the data comes from, and prevents naming conflicts ($_GET["id"] and $_POST["id"] could be two different values...)

    Always check data from $_GET and $_POST ($_REQUEST) array, make sure no harmfull code is submitted.

    $_SESSION data is more secure, because it lives on the server and it is you who desides what is stored in it.
    zalucius

  7. #7
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $_REQUEST combines $_GET, $_POST and $_COOKIE (GPC familiar?). As mentioned you can have naming conflicts. The order in which these variables are filled is controlled within php.ini. It's much better to use the individual super globals.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •