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.
Related
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
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 4 years ago.
Improve this question
I am trying to make this page:
https://mediastreet.ie/media-jobs/role-65678
same as this page using htaccess:
https://mediastreet.ie/media-jobs/role
So basically /role-65678 is a parameter like role-{parameter}. So when on /role-65678 i have a script that fetches this (65678) and displays the job according to it.
Rather than editing your htaccess file, I would just reccomend sticking with a good old get method.
Use https://mediastreet.ie/media-jobs/role?id=65678
Then in the index.php file in the directory "role", use the get functionality as shown below.
<?PHP
$id = $_GET["id"];
//Code to follow
?>
Past experiance tells me this will save alot of htaccess headaches!
All the Best.
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 6 years ago.
Improve this question
I currently don't even know what exactly to search, don't know if that procedure has a name or something, that's why i decided to post a question.
For example, when i hit mysite/test.php i want that php to make a request to another .php on another server and get all the html contents of that page and echo it in test.php, is that even possible?
Let's suppose test.php is that php file which makes a request to take_me.php .
take_me.php could have just an echo or it could be a full content page.
Can i have the content of take_me.php shown in test.php?
You could use file_get_contents and echo to screen like below:
$html = file_get_contents('http://www.google.com');
if (isset($html)) {
echo $html;
}
You may have issue with images rendering correctly etc... due to paths but it will work.
http://php.net/manual/en/function.file-get-contents.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 7 years ago.
Improve this question
Go!
like this code but using php thanks
You can change location with php:
header("location:somewhere.php");
but in the same tab - php will not tell the browser to open it in new tab. This must be done by javascript after reloading by the header function, but you will not know if it will open in new tab or in new window anyway - it is up to the browser settings!
Remember that you cannot output even single character to the browser (no echo, no html tags) before calling header function.
I'm not really sure that's what you want it, but it is what I understood.
<?php
echo 'Go!';
?>
Did you know you can name a file .php and still have php and html code on it? you just have to put at the start and end of the code and then just write rest on html outside of those code brackets.
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 know that the usual method for handling a form with PHP is to POST to a script like this:
echo("<form action='handleForm.php' method='post'>");
it possible to POST directly into a text file like this:
echo("<form action='formData.txt' method='post'>");
?
If you want to append the text into the file, it won't.
POST is a type of request to the server to send data. HTTP server will answer with your txt file, and the browser will show that. As the server as default is not able to run any kind of txt codes, nothing will happen. You can set up different codes, how to handle these files.
There are a lot of types of request, read further if you interested in.