Jump to content

Help adding <a href> to echo


johnnyboy16

Recommended Posts

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>'; 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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>'; 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>';

Link to comment
Share on other sites

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>'; 

  }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.