How do you map HTTP inputs to functions? [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a script, let's call it myScript.php. It's one of several scripts.
I want to pass certain things to it via the HTTP address, like this: …/myScript.php?format=xml&action=courses where xml is the format and the action is a query some courses in my database.
But I want also to be able to assign …/myScript.php?format=json&action=courses in the same script.
How can I do this?

You can reference any parameters passed in the url like so in php: $_REQUEST['format'], $_REQUEST['actions']. You can then assign them to a variable and change that variable in your script.
fetch('./myScript.php?format=xml&action=courses')
$_REQUEST['format'] //xml
$_REQUEST['actions'] //courses
REQUEST is the general method but you can also use GET. Refer to this for more info: https://stackoverflow.com/a/1924958/11945488

$_REQUEST=array_merge($_POST,$_GET,$_COOKIE);
in native php global request variable include get post and cookie ..
You should get parameters with global variable $_GET,
if you does $_REQUEST maybe can confusion php

Related

PHP webshell pass the value using wget or URL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have PHP-shall and I want to pass a value for the eval function. I want to pass the value to "mypass", is it possible to do so with URL or command line?
<!--?php eval($_POST[mypass]);?-->
I cannot explain to you how dangerous this is. To have eval in it's own can be a massive hazard to the system, forget having user input being processed by eval. You could run things that would control the entire system. That being said, your php is opening and closing wrong
<?php Not <!--?php
Next your var isnt being accessed as expected, you forgot the dollar sign:
$_POST[$mypass] unless the parameter is "mypass" which it should be $_POST["mypass"]
Lastly, you'll find that in a post, you can't use your browser. Use postman or change $_POST to $_GET

Laravel: How to read GET_Parameter from URL on EACH page? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am doing a laravel project and want to be able to read a GET Parameter from the URL on each Page. With this optional parameter (url?color=blue) i want to switch between two differen color shemes.
This parameter should be accessable from each page. My function is already prepared and works pretty good. But of course, i won't place this function on each controller and / or view.
So my question is: Is there any posibility to place this function on a central component? Where should i place it?
Session
Perhaps you should consider saving this variable in a session? See the Laravel documentation about this. Sessions provide a way to store information about the user across multiple requests. This seems a solution to what you're trying to achieve persisting the query parameter for every request.
Middleware
To answer your question: you could probably write Middleware to interact with this query parameter. Though it seems counter-intuitive for your use case.
The implementation depends on what you would lke to do with the variable.

Is it possible to pass some data to PHP script which is called thru header('Location: ') [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a PHP script which invokes another PHP script thru header("Location:"). Is it possible to pass some data to that second script, e.g. login name. That second script uses POST as its form's method. Currently I pass data thru file on server
As this basically just redirects the browser to the url specified in your Location header you can not simulate a POST request here.
What you can do is to send GET-parameters with the requets.
For example you could do this:
<?php
header("Location: nextpage.php?login_name=".$login_name);
Then you would access this in the nextpage.php code with $_GET['login_name'].

php - understanding this->request->post [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm studying someone else's code in order to learn php,html and something I don't understand is this:
if (isset($this->request->post['eid'])) {
$eid = $this->request->post['eid'];
} else {
$eid = '0';
}
How exaclty is the value of the field eid passed to the php file that just opened and how can I use this mechanism to pass values to other files? And secondary..what is different when get is used instead of post at the same statement?
The -> arrow operator is used to get variables and functions that belong to an object.
In this case, $this is an object and you're getting the varible request from that object. That variable contains another object which has a variable post. That variable is an array and you're getting the value with index "eid" from that array using post['eid'].
$this->request->post['eid'] is same as $_POST["eid"] in simple words.
$this->request->post['eid'] is used in the frameworks. $_POST is the array of values which you get on form submission.

How can I transfer http header to another page? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I would like to know if it is possible to transfer a defined header to another page. For example in PHP, I want to send http header value to a new page.
I don't know if it's possible. PHP or JavaScript is fine.
Yes, you can. Let's say you have some data that you want to send to another file via HTTP, you could do something like I have shown below.
FirstFile.php
<?php
$someVar = "SomeValue";
header("Location: SecondFile.php?someVar=" . $someVar);
?>
So, in the above code, you learn how to transmit data to a new file, now to retrieve and utilize that data, you should do the following as I have done.
SecondFile.php
<?php
$someVar = $_GET['someVar'];
?>
You use the $_GET to achieve this. You can know more about this here.

Categories