wholee1
wholee1

Reputation: 1501

PHP a href link with print or echo

I have quick question about a herf link in php field. When I try to make a href link in php field by using echo or print, it does not work the link. Could you see the code briefly? Thanks!

if(isset($_SESSION["manager"])){
    echo "<div id=\"login_link\">
            Welcome Admin!<br>
            <a herf=\"storeAdmin/admin_logout.php\">Log out</a>
            </div>"; 
    }

Upvotes: 0

Views: 17410

Answers (5)

Mwangi Thiga
Mwangi Thiga

Reputation: 1369

Had the same problem but its because I was using

echo "".htmlspecialchars($errorMessage)."";

removing the htmlspecialchars fixed it for me.

Upvotes: 0

evan.stoddard
evan.stoddard

Reputation: 698

also just a suggestion, you can always use ' inside of " instead of having to cancel your quotes. Atleast it works for me

Upvotes: 1

Xyz
Xyz

Reputation: 6013

  1. It is href="" not herf=""
  2. It is good practice to refrain from using relative links, as it is likely to cause issues in more complex sites. Use something like href="/root-path-to-your-stuff/storeAdmin/admin_logout.php"

Upvotes: 1

Dips
Dips

Reputation: 3280

Here I have updated your code

if(isset($_SESSION["manager"])){
        echo '<div id=\"login_link\">
                Welcome Admin!<br>
                <a href=\"storeAdmin/admin_logout.php\">Log out</a>
                </div>'; 
        }

Upvotes: 1

bjrnt
bjrnt

Reputation: 2822

It should be href="...." not "herf".

For more info about the a tag you can take a look here: http://www.w3schools.com/tags/tag_a.asp

Upvotes: 8

Related Questions