Which is the difference between $_get & $_post in PHP?

8 replies
I want get the difference please tell actual
#$get #$post #difference #php
  • Profile picture of the author mojojuju
    Signature

    :)

    {{ DiscussionBoard.errors[8777033].message }}
  • Profile picture of the author XTractor
    GET is the data sent to the server in the URL:
    For example:
    SOMETHIGN.com?a1=data&a2=moredata

    so the server get's the array: [a1=>data, a2=>moredata]

    Post is data sent through the HTTP and it is not visual to the user.
    {{ DiscussionBoard.errors[8778267].message }}
    • Profile picture of the author pawanzz
      Hello
      The basic difference between $_get and $_post is
      In the $_get method is restricted to send upto 1024 characters only and the PHP provides $_get associative array to access all the sent information using GET method.Other hand $_Post method does not have any restriction on data size to be sent and the post method can be used to send ASCII as well as binary data.The PHP provides $_Post associative array to access all the sent information using POST method.
      {{ DiscussionBoard.errors[8780751].message }}
      • Profile picture of the author rogerlegend
        $_GET, $_POST and $_REQUEST all these variables are predefined variables in php. Normally we have 2 methods to send the data to one page to another page. Those methods are nothing but GET and POST methods. Using this variable we can get the data by specifying the variable name for example, $_GET['name'], $_POST['email'] and $_REQUEST['phone'].

        Using GET method:
        we can get the data from URL
        Example: www.example.com/index.php?name=phptag
        Now from the above URL if you want to get the phptag value see the code below

        <?php

        $name = $_GET['name'];
        //or
        $name = $_REQUEST['name'];

        ?>

        Using POST method:
        we can get the in hidden mode, that means we cannot see the data in URL it will carry through the headers.
        Normally we can use the post method by implementing the html form's see the code below

        <form name='phptag' method='post'>
        <input type='text' name='name' value='phptag'>
        <input type='submit' name='demo' value='Click' >
        </form>
        <?php

        $name = $_POST['name'];
        //or
        $name = $_REQUEST['name'];

        ?>
        Please visit connected commerce site have used lot of post and get methods.
        In the above examples the common thing that we have used is $_REQUEST which means it can be used for both GET and POST methods to get the data.
        Signature

        Thanks,
        Roger,
        connected commerce

        {{ DiscussionBoard.errors[8809150].message }}
  • Profile picture of the author softwarewarden
    Originally Posted by rogerlegend View Post

    $_GET, $_POST and $_REQUEST all these variables are predefined variables in php. Normally we have 2 methods to send the data to one page to another page. Those methods are nothing but GET and POST methods. Using this variable we can get the data by specifying the variable name for example, $_GET['name'], $_POST['email'] and $_REQUEST['phone'].

    Using GET method:
    we can get the data from URL
    Example: www.example.com/index.php?name=phptag
    Now from the above URL if you want to get the phptag value see the code below

    <?php

    $name = $_GET['name'];
    //or
    $name = $_REQUEST['name'];

    ?>

    Using POST method:
    we can get the in hidden mode, that means we cannot see the data in URL it will carry through the headers.
    Normally we can use the post method by implementing the html form's see the code below

    <form name='phptag' method='post'>
    <input type='text' name='name' value='phptag'>
    <input type='submit' name='demo' value='Click' >
    </form>
    <?php

    $name = $_POST['name'];
    //or
    $name = $_REQUEST['name'];

    ?>
    Please visit connected commerce site have used lot of post and get methods.
    In the above examples the common thing that we have used is $_REQUEST which means it can be used for both GET and POST methods to get the data.
    not 100% correct $_REQUEST = data from $_GET, $_POST, and $_COOKIE
    {{ DiscussionBoard.errors[8809214].message }}
  • Profile picture of the author YHmuWong
    It is mostly how the script reacts to the data.$get is pass it as visual to the user while $post is to pass it as http and hidden to the user.Obviously,$post is safer than $get protocol, who wants their information being posted on the site they visit.
    Signature

    Number 11 is lucky in snake & ladders.

    {{ DiscussionBoard.errors[8809257].message }}
    • Profile picture of the author nettiapina
      Originally Posted by YHmuWong View Post

      It is mostly how the script reacts to the data. is pass it as visual to the user while is to pass it as http and hidden to the user.Obviously, is safer than protocol, who wants their information being posted on the site they visit.
      POST is not much safer than GET unless there's something else to make it safer. You're still POSTing information to the site you're visiting. It's all in clear text unless you're using some form of encryption.

      Sure, the variables aren't visible in your address bar, and it might be harder to get the data from your browser history, but these are just side effects.
      Signature
      Links in signature will not help your SEO. Not on this site, and not on any other forum.
      Who told me this? An ex Google web spam engineer.

      What's your excuse?
      {{ DiscussionBoard.errors[8813515].message }}
  • Profile picture of the author Andrew H
    It amazes me how much people 'think' they know (and how positive they seem in their answers). ~%20 of information in these responses is incorrect.

    $_GET = PHP: $_GET - Manual
    $_POST = PHP: $_POST - Manual
    $_REQUEST = PHP: $_REQUEST - Manual
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[8812018].message }}

Trending Topics