I'm working with PHP and in this instance I want to pass $_SESSION
which I've already assigned with my currentUser
object. This works fine.
I've used the header function to pass variables between pages such as header('Location: example.php?uID='.$uID)
and then using GET to receive this value.
However, instead of using a header to automatically redirect, I want to use a href
so that the user has to click on a link, which then initiates the redirect.
The problem is that I use the anchor (<a>
) inside the PHP tags and I can't pass variables using it inside the HTML tags.
I'd be very grateful for the solution and happy to elaborate. Thank you!
答案 0 :(得分:0)
你可以这样做:
//assuming that the user id is stored in the 'uID' field of $_SESSION
<a href="<?php echo 'exemple.php?uID='.$_SESSION['uID']; ?>">Redirect me !</a>