php - Nav Bar issue: only show links in nav bar when logged in as admin[SOLVED] -


i want code show when im logged in admin have written code exept when add like

<a href=""></a> 

in php code crashes

so when use:

</html>  //check if logged in <?php  session_start(); $loggedin = $_session['loggedin']; $loggedinadmin = $_session['positief'];  ?>  //or have use code below check if logged in (i can leave out if ($loggedin)  <?php session_start(); // start session $loggedin = $_session['loggedin']; // loggedin?  // not logged in, kill page , ask them login. if ($loggedin != "1") { die('sorry not logged in, please click <a href="testlogin.php">here</a> login');}  $logadmin = $_session['logadmin']; // loggedin?  // not admin, kill page , ask them login. if ($logadmin != "1") { die('you have no power here! click <a href="test.html">here</a> return shell');} //in line above need edit? doesn't show items have no rights for?  ?>  // css code <head> <link href="style2.css" type="text/css" rel="stylesheet"/> </head>  //nav bar , links <div id="nav"> <div id="nav_wrapper"> <ul> <li><a href="#">home</a></li> <li><a href="#">login</a></li> <li><a href="#">edit app</a></li> <li><a href="#">preview</a></li> <li><a href="#">logout</a></li>  //exeption admin <?php $adminit="it admin"; $verzend="verzendingen"; $verzond="verzonden"; $magazij="magazijn";  if ($loggedinadmin) {  echo "<li>$adminit</li>"; echo "<li>$verzend</li>"; echo "<li>$verzond</li>"; echo "<li>$magazij</li>";  }  ?>  </ul>  </div> </div>   </html> 

this code, made notices explain have done. or ask advice.

anyone taking time @ , try in advance!

greetings,

dtcodedude

how solved it;

<?php session_start(); $loggedin = $_session['loggedin']; $logadmin = $_session['logadmin'];// checks if got adminrights // (if intrested in auth code post below).  $home="index.php"; $login="login.php"; $edit="navbase.php"; $preview="preview.php"; $logout="logout.php";  $adminit="adminbase.php"; $verzend="verzend.php"; $verzond="verzonden.php"; $magazij="magbase.php"; $host=""; $username=""; $password=""; $db_name="";  $conn = mysql_connect("$host", "$username", "$password")or die("cannot connect host"); mysql_select_db("$db_name")or die("cannot select db");  $sql="select * users";  $result = mysql_query($sql, $conn);  ?>  <head> <link href="style2.css" type="text/css" rel="stylesheet"/> </head>  <div id="nav"> <div id="nav_wrapper"> <ul>  <?  if ($result) {  echo " <li><a href=\"$home\">home</a></li>"; echo " <li><a href=\"$login\">login</a></li>"; echo " <li><a href=\"$edit\">edit app</a></li>"; echo " <li><a href=\"$preview\">preview</a></li>"; echo " <li><a href=\"$logout\">logout</a></li>";  } else {  die ('crash');  } ?> <?  if ($logadmin) {  echo " <li><a href=\"$adminit\">it admin</a></li>"; echo " <li><a href=\"$verzend\">verzendingen</a></li>";  echo " <li><a href=\"$verzond\">verzonden</a></li>"; echo " <li><a href=\"$magazij\">magazijn</a></li>";  }else{   }  ?>  </ul>  </div> </div>   </html> 

you can add php code inside html code this.

<li><a href="<?php echo $url; ?>"><?php echo $adminit; ?></a></li> 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -