Is it possible to send $_POST
variable via the URL without using a form
? or other "invisible"
type of variable in the URL
.
My situation :
There is a request (from server "ZETA") which calls my php script via the URL
but this script needs my file name (thats the variable I want to send). So I know I can use $_GET
but I don't want to send the file name in clear in the URL
.
So is it possible or I'm just wasting my time :p
ps : only html and php, please.
Thx
Update 1
This is how I call my script :
http://10.13.48.60/XML_MYSQL/xml_to_mysql.php?name=1201072-14913200.xml
I just want to make the var "name" invisible when I send.
No. PHP will populate $_GET
with data from the URL and only use the request body to populate $_POST
.
You can't put unencrypted data in the URL without it being visible to anyone who can see the request (for that matter, you can't put unencrypted data anywhere in the request without it being visible to them).
If you don't want to send the data in the clear, use HTTPS instead of HTTP. This will protect the request from being intercepted (although anyone at either end can still see the data… but since one is creating it and the other is supposed to read it, that should not be a problem).
In order to use POST, you will need to use a tag, and depending on how you are pulling up these URLs, it could be easier to use javascript to help out. Here's a basic example:
<form method="post" action="data.php">
<input type="hidden" name="parameter" value="1234" />
<input type="submit" value="Go" />
</form>
The Go button would POST the form data, and now in data.php you will be able to retrieve the value from $_POST['parameter']. Note that when using POST, you will probably want to redirect (HTTP 302) back to a page so that when a user hits the back button, the browser doesn't prompt to resubmit the form.
Using javascript, you could set the parameter input to a different value before posting the form.