I have three values that I want to pass via a link, 开发者_运维知识库but don't want them visible in the URL.
I have three values that I want to pass via a link, but don't want them visible in the URL.
Your statement is contradictory to itself. You want to show in link but at the same time you don't want to show it in the url.
Alternatively, you can use hidden fields to pass your data or even use session.
There are two main methods to do it:
Firstly, if you're using forms:
<form action="submit.php" method="POST">
... stuff ...
</form>
This will store the form contents into PHP's $_POST array, depending on the element name. So, if you have an element with name="foo"
, it'll go into $_POST['foo']. You can use hidden form fields (type="hidden"
) so that they don't display.
Another way is via sessions (think of them as server-side cookies), stored inside of $_SESSION:
session_start();
$_SESSION['foo'] = value;
If you want to remove all the session variables, use session_destroy()
.
See here for more info: http://www.php.net/manual/en/ref.session.php
you can pass these variables in a hidden form with POST. Alternatively, you could encode the values somehow so they are not human readable.
Then you've got a problem, as a link is basically a URL that the browser will follow when clicked. You could simply include the values in the link URL and have the page that URL identifies redirect to another URL. That way, at least the values won't show up in the address bar. Whether or not this will achieve your overall goal, I couldn't say.
Figured it out using this example with javascript. http://www.skytopia.com/project/articles/compsci/form.html#form2php
精彩评论