Here one main concern is the data gets exposed in address bar of the browser and can be easily accessible by using browser history. So it is not a good idea to pass sensitive data like password,personal information or confidential business data through the URL to different pages or different sites.
<a href='page2.php?id=2489&user=tom'>link to page2</a>
When the above link is clicked, page2.php gets the variables id and user with data 2489 and tom respectively. Here is the code to collect data in PHP.
echo $_GET['id']; // output 2489
echo $_GET['user']; // output tom
<a href=https://www.sitename.com/index.php?id=2489&user=tom>Link to another site</a>
Demo of passing data through a form <form method=GET action='https://www.anysite.com/index.php'>
$id=$_POST['id'];
$password=$_POST['password'];
issues | GET | POST |
---|---|---|
Browser History | Data remain in Browser History | Data Not available in Browser History |
Bookmark | URL with Data can be bookmarked | No data is available in URL to bookmark the page |
Data Length Restriction | The restriction (of URL ) is applicable | No Restriction |
cached | Can be cached | No meaningful caching |
Sensitive Data | Data like password , pin etc. are exposed through URL so they should not be passed using GET method | Better than GET method as data is not exposed through URL |
$id=$_REQUEST['id'];
$password=$_REQUEST['password'];
$id=$_GET['id'];
$user=$_GET['user'];
Same way in ASP environment running VB script the data can be collected and assigned like this
Id = Request.QueryString("id")
User = Request.QueryString('user')
<a href=https://www.sitename.com/viewtopic.php?id=5248>Linking to a topic</a>
$pid=$nt[product_id];
echo "<a href=product-detail.php?product_id=$pid>Product Details</a>";
You can directly display like this also.
echo "<a href='product-detail.php?product_id=$nt[product_id]'>Product Details</a>";
ash | 28-07-2009 |
How to pass a file via URL. Eg a file is uploaded in using doGet() and in doPost it is collected using request.getInputStream() |
kashif murtaza | 23-10-2009 |
thanks for help... it's good for understanding concept of href.. |
campsmore | 08-02-2010 |
Can you use the data variable that was passed in the URL in an "include" statement to display information inside the current page that is related to the data in the variable? |
ruby | 14-02-2010 |
how to data transfer between two members in login concept |
BigDave | 27-05-2010 |
In the first example, what if, instead of sending Tom, I need to send the value of a variable? |
ramchan | 23-07-2010 |
I need a help in PHP of passing a content of search result from one web site to another web site. I am not having any idea about this can u help me sir. |
Sashi | 18-08-2010 |
How can i rethieve the mode/id values into an xsl page of the following url line... http. localhost/updatingXML/tool_Edit.asp?mode=view&id=2 |
smo | 22-08-2010 |
In ASP the get method of collecting data |
jessica | 23-08-2010 |
how can i pass values with a drop down menu which contains a list of manufacturers name.i want the code to display a value of a variable each time a manufacturer name is selected through the drop down |
JohnR | 12-10-2010 |
What PHP code do I use to Post form data to a MYSQL database and at the same time send only some form values to another web page hosted on a different URL.? Thanks! |
siva | 13-12-2010 |
i can understood the $_POST, but how $_GET works , |
adi | 11-09-2011 |
which menthod gets executed when we click on hyperlink? |
Power Wong | 25-01-2012 |
adi, should be $_GET method. For example, the url is: xxxxxx/my_prog.php?my_id=1234 Then inside my_prog.php, you can use $_GET[my_id] to get the 1234 like the below $my_var = $_GET[my_id] |
David | 22-03-2012 |
I have 2 separate php environments which I like to have a pass-through of registration and login built. Any help will greatly be appreciated. |
debabrata puthal | 07-04-2012 |
create a form with 2 fields that is username and password then make the server side validation chec if the fields and blank or not,then compare your username and password with server username,password,if equal display on page valid user or display invalid user. |
tripti | 06-06-2012 |
i need to get how to send an ip address value to ip2location text box to evaluate the location n return it |
Jobaiyet | 02-03-2014 |
How use a php variable in various page??? |
Dhivya | 12-09-2014 |
how to pass a variable in one page to other using get method but that passing variable should not shown in the url i tried more method i donn't know is it possible if it possible meance pls post |
Rhys | 23-10-2014 |
Thank you. =) |
Mohammad Ismail | 15-09-2015 |
i neeed to link first two dropdown boxes and next two dropdown boxes bt they should not be related to each other. . .and also when i perform first one box second box sholud display untill then second box should nt display any info. . plsss help me out |
02-12-2019 | |
i need to post data one page to another page. i did post data by using jqueryajax and next page i created session but can't work... how to solve this......... |
02-03-2020 | |
hello hii, how can i run html code in url bar for ex. http://website.com/<h1>cotent</h1> this code is not execute |
04-03-2020 | |
You can't run html code at URL bar, you can pass them as variable and display them inside the page. |
28-04-2021 | |
Thank You so Much! Litteraly, I am newbie and searching for Alternative to HTML Form..... This is too useful |
28-08-2021 | |
how i can pass id with post in php please help me |