Jump to content

[SOLVED] If then else - with web link


compunet2

Recommended Posts

I'm trying to run the following code in my webpage.  The problem is with the html link.  What I want to happen is if the "REMOTE_USER" is equal to the values I specify, I want a url and image to appear.  Otherwise, I want nothing to appear.  Here is what I have so far:

 

 

<?php

 

$number_three = $_SERVER['REMOTE_USER'];

 

if ( $number_three == "dsmith" or "jdoe") {

<a href="http://www.domain.org/members/admin/"><img src="http://www.domain.org/images/admin.jpg" alt="Administration"  vspace=2 border=0></a>;

} else {

echo " ";

}

 

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/154666-solved-if-then-else-with-web-link/
Share on other sites

Use an array then the in_array function.

 

<?php
$number_three = $_SERVER['REMOTE_USER'];

$validNames = array("dsmith", "jdoe");

if (in_array($number_three, $validNames)) {
    echo '<a href="http://www.domain.org/members/admin/"><img src="http://www.domain.org/images/admin.jpg" alt="Administration"  vspace=2 border=0></a>';
} 
?>

Archived

This topic is now archived and is closed to further replies.

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