I'm working on an if else statement that will display a custom link for everyone except Company A. Everything below works just fine, but it's imperative Company A not see the first link.

I've tried something along the line of:

<?php
$nolink = "Company A";
if ($_SESSION['company'] != $nolink);{ //display the link...etc
?>

...but the problem is, my custom link has nested php scripts. I think I'm on the right track, but I'm stuck. Again, my code below works except that I want the first link to disappear for Company A.

<h1>Welcome, 
<?php //display company name inside the h1 tag
if (!session_register(company));{
echo $_SESSION['company'];}
?>
</h1>

<p>
<!--DISPLAY THIS LINK FOR EVERYONE EXCEPT COMPANY A-->
<span style="margin-left: 50px;">
<a href="<?php  echo "folderName/" . $_SESSION['company'] . "/" ?>">&raquo; Go To <?php echo $_SESSION['company'];?> Account Info</a>
</span><br />

<!--DISPLAY THESE LINKS FOR EVERYONE-->
<span style="margin-left: 50px;">
<a href="link2.php">&raquo; Go To Link 2</a>
</span><br />
<span style="margin-left: 50px;">
<a href="link3.php">&raquo; Go To Link 3</a>
</span>
 </p>
Member Avatar for langsor

Sometimes it's challenging to not mix up your html tags and php code, but as much as you can manage them as separate logical pieces, the easier it is to make it all work ... in my opinion.

Something like this might work -- though this is off the top of my head and untested

<?php
// I may have messed this up some but it looked ... odd to me
if ( ! session_register('company') ) {
  $company = $_SESSION['company'];
}
// make your link  here
$link = <<<ENDLINK
    <span style="margin-left: 50px;">
      <a href="folderName/$company/">&raquo; Go To $company Account Info</a>
    </span><br />
ENDLINK;
// match $company to Company A and go from there
$output = ( $company == 'Company A' ) ? $link : '';
?>
<html>
<head>
</head>
<body>
  <h1>Welcome, </h1>
  <p>
    <!--DISPLAY THIS LINK FOR EVERYONE EXCEPT COMPANY A-->
<?php print $output ?>
    <!--DISPLAY THESE LINKS FOR EVERYONE-->
    <span style="margin-left: 50px;">
      <a href="link2.php">&raquo; Go To Link 2</a>
    </span><br />
    <span style="margin-left: 50px;">
      <a href="link3.php">&raquo; Go To Link 3</a>
    </span>
  </p>
</body>
</html>

Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.