Passing values to next page using anchor tag
Solution 1
You said that you don't want anything in the url to be shown except from page name so why not using a form with psot method? Post will not show anything in the browser and you won't have to deal with sessions/cookies which require more work.
From documentation
- POST requests are never cached
- POST requests do not remain in the browser history
- POST requests cannot be bookmarked
- POST requests have no restrictions on data length
<form method="post" action="index1.php">
<input type="hidden" name="name" value="username" />
<input type="hidden" name="username" value="123" />
<input type="submit" name="submit" value="submit" />
</form>
Now in your second page you just need to retrieve data you need throw variable $_POST['name']
and $_POST['username']
. You can also make your submit button look like a link with some css.
Solution 2
You can use the session variable to pass the value from one page to another page.
user3350885
Updated on June 04, 2022Comments
-
user3350885 almost 2 years
One quick question -
I have an anchor tag which on clicking opens a new target window.
I don't want to pass the values either in post or get method.
my html code is like this.
<a class="employee_details" target="_blank" href="index1.php?name=username&id=123">UserName</a>
Is there a way to pass the values to the next page using jquery in a hidden type since there is no submit button. In other words, clicking the anchor tag will redirect to another one page where i should get the name and id and that part should NOT BE VISIBLE ANYWHERE in the url.
Any help Kimz
-
AO_ about 10 yearsYou should keep the
anchor
outside of theform
in this case to preserveinline-display
.. -
Rohit Awasthi about 10 yearsinline-display means?
-
AO_ about 10 years
Form
is adisplay:block
element which will force the other elements around the anchor to not share the line it sits on..... e.g. w3schools.com/cssref/…