Welcome to the Webmaster Forum.
Results 1 to 12 of 12
Like Tree1Likes
  • 1 Post By SimplySidy

Thread: Get and post method

  1. #1
    Member
    Join Date
    Apr 2013
    Posts
    36

    Get and post method

    What are the differences between Get and post methods in form submitting.
    give the case where we can use get and we can use post methods?

  2. #2
    Senior Member
    Join Date
    Aug 2013
    Posts
    200

    Re: Get and post method

    Get and post method are use to transfer the data of one page to other.But difference b/w get ant post is that in get method information of data is shown in url but in post method it is not shown why which post method is more secure.in form tag in action attribute we use this method which transfer the data. if although you have any query so plz visit the w3school.com site .where more detail are given.

  3. #3
    Senior Member
    Join Date
    Aug 2013
    Posts
    200

    Re: Get and post method

    The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
    The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.
    Example

    The example below contains an HTML form with two input fields and a submit button:
    <html>
    <body>

    <form action="welcome.php" method="post">
    Name: <input type="text" name="fname">
    Age: <input type="text" name="age">
    <input type="submit">
    </form>

    </body>
    </html>

    When a user fills out the form above and clicks on the submit button, the form data is sent to a PHP file, called "welcome.php":

    "welcome.php" looks like this:
    <html>
    <body>

    Welcome <?php echo $_POST["fname"]; ?>!<br>
    You are <?php echo $_POST["age"]; ?> years old.

    </body>
    </html>

    Output could be something like this:
    Welcome John!
    You are 28 years old.

  4. #4
    Senior Member
    Join Date
    Jul 2013
    Location
    Bhubaneswar, Odisha, India
    Posts
    112

    Re: Get and post method

    The Get will stuff the input in the URL and hence it should not be used to send Passwords. Also, when there are files to be uploaded, the Method for the form should be POST. That is more on the HTML sides and all of the data sent to PHP depends on what you should use on the server.
    MedicAlert likes this.

  5. #5
    Senior Member
    Join Date
    Feb 2013
    Posts
    123

    Re: Get and post method

    Quote Originally Posted by SimplySidy View Post
    The Get will stuff the input in the URL and hence it should not be used to send Passwords. Also, when there are files to be uploaded, the Method for the form should be POST. That is more on the HTML sides and all of the data sent to PHP depends on what you should use on the server.
    Wow, I did not know that. Thanks for the simple answer. Also, if I wanted to take the information from a form or something and put it into my backend PHP code, would I need POST?

  6. #6
    Banned
    Join Date
    Dec 2013
    Posts
    86

    get and post

    The main difference between get and post is:-
    we can change the data run time in the post method and in the get method we can not change the data.........

  7. #7
    Member
    Join Date
    Mar 2014
    Posts
    38

    Re: get and post

    Get and Post are both methods of php.The main use of the get and post is transfer data into the database.get is fixed we cannot change the data at the run time and in the post method we can change the data,............

  8. #8
    Senior Member
    Join Date
    Jun 2014
    Posts
    365

    Re: Get and post method

    using get method is not secure, your informations will be appeared in the url address. using post method is much secure it will not appear in the url

  9. #9
    Member
    Join Date
    Jul 2014
    Location
    Thessaloniki, Greece
    Posts
    59

    Re: Get and post method

    when you "grab" the variables, instead of using $_GET or $_POST, you can also use $_REQUEST.
    With $_REQUEST you dont mind if a variables its from post or get method. It always "grabs" it!

  10. #10
    Member
    Join Date
    May 2014
    Posts
    73

    Re: Get and post method

    By get method our data show in address bar, and by post it is not show in address bar.

  11. #11
    Junior Member
    Join Date
    Jul 2014
    Posts
    18

    Re: Get and post method

    The GET Method

    The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character.

    The GET method produces a long string that appears in your server logs, in the browser's Location: box.

    The GET method is restricted to send upto 1024 characters only.

    Never use GET method if you have password or other sensitive information to be sent to the server.

    GET can't be used to send binary data, like images or word documents, to the server.

    The data sent by GET method can be accessed using QUERY_STRING environment variable.

    The PHP provides $_GET associative array to access all the sent information using GET method.

    Try out following example by putting the source code in test.php script.

    <?php
    if( $_GET["name"] || $_GET["age"] )
    {
    echo "Welcome ". $_GET['name']. "<br />";
    echo "You are ". $_GET['age']. " years old.";
    exit();
    }
    ?>
    <html>
    <body>
    <form action="<?php $_PHP_SELF ?>" method="GET">
    Name: <input type="text" name="name" />
    Age: <input type="text" name="age" />
    <input type="submit" />
    </form>
    </body>
    </html>

    The POST Method

    The POST method transfers information via HTTP headers. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.

    The POST method does not have any restriction on data size to be sent.

    The POST method can be used to send ASCII as well as binary data.

    The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.

    The PHP provides $_POST associative array to access all the sent information using POST method.

    Try out following example by putting the source code in test.php script.

    <?php
    if( $_POST["name"] || $_POST["age"] )
    {
    echo "Welcome ". $_POST['name']. "<br />";
    echo "You are ". $_POST['age']. " years old.";
    exit();
    }
    ?>
    <html>
    <body>
    <form action="<?php $_PHP_SELF ?>" method="POST">

    Name: <input type="text" name="name" />
    Age: <input type="text" name="age" />

    <input type="submit" />
    </form>
    </body>
    </html>

  12. #12
    Junior Member
    Join Date
    Dec 2014
    Posts
    13

    Re: Get and post method

    I think it's a best practise to use $_POST method in forms to submit some kind of data to database, so users can't see what's being send.
    And using $_GET method is best, when you need to retrieve some information from database.
    For example, if you have news.php file and need to read the first item, this solution would be pretty normal: news.php?id=1

 

 

Similar Threads

  1. How often do you post on your blog?
    By Shawn Gossman in forum Blogging & Content Management Systems
    Replies: 36
    Last Post: 10-07-2018, 06:03 AM
  2. Replies: 73
    Last Post: 06-14-2016, 06:12 AM
  3. Social Bookamrking Submission Method
    By arpit.bhateley in forum Search Engine Optimization (SEO)
    Replies: 12
    Last Post: 04-20-2016, 02:31 AM
  4. CPA Method
    By Ryan21 in forum Affiliate Programs & Affiliate Marketing
    Replies: 4
    Last Post: 03-06-2016, 10:34 AM
  5. Paid to Post Content
    By scottyxx in forum Blogging & Content Management Systems
    Replies: 23
    Last Post: 08-09-2013, 11:14 PM

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
  •  
Back to top

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203