Making a Link Appear if a Condition is Met
- by John
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();
}
?>