geroido Posted August 21, 2008 Share Posted August 21, 2008 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 More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 <p><a href="listmen.php?resid=<?php echo $_SESSION['resmenuid']; ?>">Back to menu...</a></p> Link to comment https://forums.phpfreaks.com/topic/120712-attach-a-variable-to-a-href-problem/#findComment-621994 Share on other sites More sharing options...
giraffemedia Posted August 21, 2008 Share Posted August 21, 2008 <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? Link to comment https://forums.phpfreaks.com/topic/120712-attach-a-variable-to-a-href-problem/#findComment-622000 Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 <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. Link to comment https://forums.phpfreaks.com/topic/120712-attach-a-variable-to-a-href-problem/#findComment-622008 Share on other sites More sharing options...
giraffemedia Posted August 21, 2008 Share Posted August 21, 2008 okey doke. Link to comment https://forums.phpfreaks.com/topic/120712-attach-a-variable-to-a-href-problem/#findComment-622019 Share on other sites More sharing options...
geroido Posted August 21, 2008 Author Share Posted August 21, 2008 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']; Link to comment https://forums.phpfreaks.com/topic/120712-attach-a-variable-to-a-href-problem/#findComment-622029 Share on other sites More sharing options...
thebadbad Posted August 21, 2008 Share Posted August 21, 2008 Well, you're not submitting a form, are you? No need of form tags then. Remember session_start() at the top of all pages using sessions. Check that $_SESSION['resmenuid'] contains what you think it does. Link to comment https://forums.phpfreaks.com/topic/120712-attach-a-variable-to-a-href-problem/#findComment-622062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.