0

I'm wanting to show an element when logged in as user. And when not logged in it is to be hidden. I get PHP Parse error: syntax error, unexpected '<'. Please any help on this and thanks upfront

<?php 

if ($_SESSION['usrname'])

{
<style type="text/css">#lah{
display:visible;}
</style>

} else {
<style type="text/css">#lah{
display:none;
}</style>

}

?>
Marc
  • 29
  • 1
  • 1
  • 5

1 Answers1

0

You are blending php with html. You need to either echo the html or drop out of php while entering the html.

Try this:

<?php 

if ($_SESSION['usrname']) {
?>
    <style type="text/css">#lah
     <?php {  ?>
     display:visible;
     </style>
     <?php
     }
} 
else {

?>
   <style type="text/css">#lah  <?php { ?>
    display:none;
    </style>

    <?php } 
}   ?>
nomistic
  • 2,902
  • 4
  • 20
  • 36