Jump to content

Attach a variable to a href problem


geroido

Recommended Posts

Hi all

Theres something wrong with my code below. I simple want to send the content of $_SESSION['resmenuid'] to listmen.php. I've done this before with a database field and it works well. I seem to have some syntax problem when it's a sesion variable. Can you see what's wrong. I think it's something to do with the ' or " positioning but I can't find the right combination. Any help?

 

<p><a href="listmen.php?resid=$_SESSION['resmenuid'] ">Back to menu...</a></p>

Link to comment
https://forums.phpfreaks.com/topic/120712-attach-a-variable-to-a-href-problem/
Share on other sites

<p><a href="listmen.php?resid=<?php echo $_SESSION['resmenuid']; ?>">Back to menu...</a></p>

 

Would...

 

<p><a href="listmen.php?resid=<?= $_SESSION['resmenuid']; ?>">Back to menu...</a></p>

 

work as well?

 

 

Maybe, but not on all servers. Its best to aviod short tags IMO.

Hi

I'm still not getting this to work. I've enclosed it in a form tag - do I have to do this?

 

<form action="listmen.php" method="get" >
<p><a href="listmen.php?resid=<?php echo $_SESSION['resmenuid']; ?> ">Back to menu...</a></p>
</form>

 

 

I have this code at the top of listmen,php to get the value and display it but no joy.

$_SESSION['resmenuid'] = $_GET['resid'];
echo $_SESSION['resmenuid'];
echo ("resmenuid is:");
echo $_SESSION['resmenuid'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.