johnnyboy16 Posted August 25, 2010 Share Posted August 25, 2010 Hi guys, I'm trying to add this link <a href="<?php CONFIG_SITE_PATH ?>/settings.php"> to somewhere in the red text below. Can someone please show me how/where I would do this. $userObj->_userId = $_SESSION['G_userId'.CONFIG_SITE_NAME]; $userObj->getUserDetails(); echo '.$userObj->_name.'</span> / <a href="logout.php" >Logout</a></span>'; Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/ Share on other sites More sharing options...
fortnox007 Posted August 26, 2010 Share Posted August 26, 2010 heya i am still a newbie but i think i can help, you code is missing something. <a href="<?php CONFIG_SITE_PATH ?>/settings.php"> I bet if you use echo in your statement it will end up in you href But I am also pretty sure that since its a variable it needs to be sanitized first. but this should work. <a href="<?php echo $sanitized_input; ?>">settings.php</a> By the way if someone know a nice way to sanitize this I am also happy to hear Because I heared htmlspecialcaracters(); isn't enough. if used it would look like this: <a href="<?php echo htmlspecialcaracters($sanitized_input, ENT_QUOTES); ?>">settings.php</a> This gives some more insight http://php.net/manual/en/function.htmlspecialchars-decode.php Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103761 Share on other sites More sharing options...
johnnyboy16 Posted August 26, 2010 Author Share Posted August 26, 2010 Thanks, but I'm not sure that is what I'm looking for. Any other suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103775 Share on other sites More sharing options...
trq Posted August 26, 2010 Share Posted August 26, 2010 Any other suggestions? You need to clarify your problem. Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103776 Share on other sites More sharing options...
johnnyboy16 Posted August 26, 2010 Author Share Posted August 26, 2010 Sorry. Ok What I'm trying to do is make the the echoed statement that I highlighted in Red, a link. The page I want to link to is the <a href> highlight in green --> "Settings.php" Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103779 Share on other sites More sharing options...
fortnox007 Posted August 26, 2010 Share Posted August 26, 2010 Well I think the answer is already there, although i also notice something else so i thought i would tell you. Also you span element doenst match. anyways I try to answer your question as far as i know what it is. I assume you want to display a username and than add a click-able text that results in logout.php Like logout johny? ok well ill give an example but still sanitize your input. And besides that i am not sure that CONFIG_SITE_PATH as is will work that well. so you might have to put it in a $var. <?php echo $userObj->_userId.', <a href="<a href="'.CONFIG_SITE_PATH.'/logout.php">Logout</a>'; ?> If this does't work try to put CONFIG_SITE_PATH in a $var. btw your code had some minor thingies marked now in red echo '.$userObj->_name.'</span> / <a href="logout.php" >Logout</a></span>'; Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103780 Share on other sites More sharing options...
fortnox007 Posted August 26, 2010 Share Posted August 26, 2010 Sorry. Ok What I'm trying to do is make the the echoed statement that I highlighted in Red, a link. The page I want to link to is the <a href> highlight in green --> "Settings.php" Oh it seems we replied simultaneously. May i ask my you dont just use hard coded <a href="/logout.php">logout</a> Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103782 Share on other sites More sharing options...
Alkimuz Posted August 26, 2010 Share Posted August 26, 2010 i'm not sure that i understand all your code, but seeing what is php and what not, does this work? (just place all between echo and alternate between html and php with code between '' and code that is not, added together with dots) $userObj->_userId = $_SESSION['G_userId'.CONFIG_SITE_NAME]; $userObj->getUserDetails(); echo '<a href="'.CONFIG_SITE_PATH.'/settings.php">'.$userObj->_name.'</a></span> / <a href="logout.php" >Logout</a></span>'; Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103784 Share on other sites More sharing options...
johnnyboy16 Posted August 26, 2010 Author Share Posted August 26, 2010 Sorry again.... echo '<span class="searchtxt"><span style="color:#3CA3E9;">'.$userObj->_name.'</span> / <a href="logout.php" >Logout </a></span>'; Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103785 Share on other sites More sharing options...
johnnyboy16 Posted August 26, 2010 Author Share Posted August 26, 2010 Got it. Thanks for the help guys. Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103787 Share on other sites More sharing options...
fortnox007 Posted August 26, 2010 Share Posted August 26, 2010 may we see your final result? Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103795 Share on other sites More sharing options...
johnnyboy16 Posted August 26, 2010 Author Share Posted August 26, 2010 Yeah, it was nothing special... $userObj->_userId = $_SESSION['G_userId'.CONFIG_SITE_NAME]; $userObj->getUserDetails(); echo '<span class="searchtxt"><span style="color:#3CA3E9;"><a href="settings.php" style="color:#3CA3E9;">'.$userObj->_name.'</a></span> / <a href="logout.php" >Logout </a></span>'; } Quote Link to comment https://forums.phpfreaks.com/topic/211743-help-adding-to-echo/#findComment-1103799 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.