GET and POST values in the same link - html

I want something like this:
link
GET and 2x POST in hyperlink. How can I do that? Nothing wants to work
I have a GET array in PHP and I want to generate a link which leads to the correct url to give me those GET variables.

You can't have 2 GET variables with the same name. You can arrange them into an array as follows:
link
Just for clarification, this is still a GET request, links cannot normally produce a POST request, nor you should try to achieve that not-normally.
EDIT: To answer OP's calrification.
If you have a $_GET array, and you want to generate a link to get you there, you can use http_build_query()

I don't think you understand what GET and POST means in the HTTP world. Any items you put on a query string of a URL are GET parameters, you can't have 2 with the same name. POST parameters are sent as a part of the request, not as a query string on the URL.

GET and POST are http operations.
Sending values by using the ? as a separator in the url is different but related. eg:
foo.com/page.php?val1=1&val2=2
The values are called Query String values.
For GET operations, values are sent as a query string values. For POST operations, the values are sent in the body of the POST request. This is why POST must be used when a lot of data is being sent to the server. (Query strings have a maximum length, HTTP requests do not.)
You can do a POST operation to a url that includes query string values. This is more common with Ajax requests but can be done in a form as well. Just set the action url to something like index.php?val1=1&val2=2 the form's (additional) values will be sent as the http body. Remember to set method="post" in the form.
Note that you will need to create the query string yourself in this example, including escaping it properly.
Repeating value names in the query string values
Usually this causes both values to be sent, but the server overwrites the variable and ends up only presenting the last one to the client software.
So if you use a url such as
<a href="http://localhost/index.php?get=abc&post=cde&post=efg">
// It will be decoded by php and most server-side frameworks as
set get to abc
set post to cde
set post to efg
Result: 2 variables, get and post

There is nothing in the HTTP standard that says you can't send two query string params with the same name. However, you won't be able to use $_GET to retrieve these values; $_GET will pick up the last one. Instead, you'll have to manually parse $_SERVER['QUERY_STRING']. It's not that hard and I've done it a number of times when PHP has to handle a URL pattern generated by a third-party tool. If you're feeling really fancy you can have your query-string parse routine generate a $_GET member as an array if more than one instance of that member is encountered.

Related

How to include SR related work log long description when using maximo oslc rest api?

I am doing an HTTP GET request to /maximo/oslc/os/mxsr and using the oslc.select query string parameter to choose:
*,doclinks{*},worklog{*},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
This lets me get related data, including related worklogs, but the worklog does not include the 'description_longdescription' field.
The only way I seem to be able to get that field is if I do a separate HTTP GET to query a worklog id directly through /maxrest/rest/mbo/worklog . Then it provides the description_longdescription field.
I understand this field is stored separately through the linked longdescription table, but I was hoping to get the data through the "next gen" oslc api with one http get request.
I've tried putting in 'worklog{*,description_longdescription}', as I read somewhere that longdescription is a "non-persistent" field and must be explicitly named for inclusion, but it had no effect.
I figured out that for the /maximo/oslc/os/mxsr object in the API, I needed to reference the related MODIFYWORKLOG object through the rel.modifyworklog syntax in the oslc.select query string:
oslc.select=*,doclinks{*},rel.modifyworklog{*,description_longdescription},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
I also had to explicitly name the non-persistent field description_longdescription for it to be included.
Ref. for the "rel." syntax: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_querying_maximo_asset_management_by_using_the_rest_api

Query Google Admin User directory comparing parameters

I'm trying to filter my users list by comparing two parameters
query="EmployeeData.EmployeeID=externalId"
EmployeeData.EmployeeID is a custom schema that is populated, with a cron job, with the same value as externalId.
Of course I let the cron do the field copy only if necessary, this is the reason I'm trying to filtering the users list.
In the way i wrote seems that the query trying to looking for a value "externalId" into the EmployeeData.EmployeeID ignoring that "externalId" is a even a field
any suggestion?
The way your code is written, the query sent to Google's servers is as you correctly guessed the following:
EmployeeData.EmployeeID=externalId where your actual externalId is not sent but rather the string "externalId".
To replace this string for the actual value of your variable, you can use what is called "string concatenation" 1. To do it, you just need to modify your code as shown below:
query="EmployeeData.EmployeeID=" + externalId;
This way, the query will be sent as you need to Google's servers.

Getting the value of a particular cell with AJAX

My goal is very simple and I would guess it is a very common goal among web developers.
I am creating a Rails (5.1) application, and I simply want to use AJAX to get the value of a specific cell in a specific row of a specific table in my database (later I am going to use that value to highlight some text on the current page in the user's browser).
I have not been able to find any documentation online explaining how to do this. As I said, it seems like a basic task to ask of jquery and ajax, so I'm confused as to why I'm having so much trouble figuring it out.
For concreteness, say I have a table called 'animals', and I want to get the value of the column 'species' for the animal with 'id' = 99.
How can I construct an AJAX call to query the database for the value of 'species' for the 'animal' with 'id' = 99 .
Though some DBs provide a REST API, what we commonly do is define a route in the app to pull and return data from the DB.
So:
Add a route
Add a controller/action for that route
In that action, fetch the data from the DB and render it in your preferred format
On the client-side, make the AJAX call to that controller/action and do something with the response.

Adding query Parameters to Go Json Rest

I am using the library go-json-rest. I'm trying to recognize queries parameters in the code for example localhost:8080/reminders?hello=world I want to access {hello: world} . I have the following code:
//in another function
&rest.Route{"GET", "/reminders", i.GetAllReminders},
func (i *Impl) GetAllReminders(w rest.ResponseWriter, r *rest.Request) {
reminders := []Reminder{}
i.DB.Find(&reminders)
w.WriteJson(&reminders)
}
I know that r.PathParams holds the url parameters but I cannot seem to find how to the query parameters past the "?" in the url.
Given that go-json-rest is a thin wrapper on top of net/http, have you looked at that package's documentation? Specifically, the Request object has a field Form that contains a parsed map of query string values as well as POST data, that you can access as a url.Values (map[string][]string), or retrieve one in particular from FormValue.

Query strings with HTTP URL

I am trying to do a HTTP GET of an URL with multiple query strings using a browser. Following is my observation
http://192.168.0.1:80/mycontent/?key1=value1 //Works.
http://192.168.0.1:80/mycontent/?key1=value1&key2=value2 //Doesen't work.
The question here :
I am finding a hard time to figure out what's the right format to
append the query string
Should we use &amp when we put in the browser?
Is there a way that I can find the validity (availability in the server) of the query string I enter in the URL.
You should use & when writing the link into HTML, for example:
Example
But not when entering the URL into the address bar, or using it directly in JavaScript (for example).
Your format is correct, so you should be able to pick up both key1 and key2 in the request collection. Depending on the language you are using on the server, the technique for this differs.