Making a Link Appear if a Condition is Met

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-06-11T08:28:15Z Indexed on 2010/06/11 8:33 UTC
Read the original article Hit count: 258

Filed under:

Hello,

The PHP code below echoes a link if the "loginid" of the logged-in user is on a list determined by getEditorList();. It works fairly well, but I think it might work better if I were to do it with Javascript instead.

How could I accomplish the same thing with Javascript?

Thanks in advance,

John

$editors = getEditorsList();
            foreach($editors as $editor)
            {
            $editorids[] = $editor['loginid'];
            }

            if(in_array($_SESSION['loginid'], $editorids))
            {
            echo "<div class='footervote'><a href='http://www...com/.../footervote.php'>Vote</a></div>";
            } 

Login function:

<?php
if (!isLoggedIn())
{

    if (isset($_POST['cmdlogin']))
    {

        if (checkLogin($_POST['username'], $_POST['password']))
        {
            show_userbox();


        } else
        {
            echo "Incorrect Login information !";
            show_loginform();
        }
    } else
    {

        show_loginform();
    }

} else
{

    show_userbox();

}



?>

© Stack Overflow or respective owner

Related posts about JavaScript