Jump to content


Photo

Getting PHP to display html.


  • Please log in to reply
4 replies to this topic

#1 olliee

olliee
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationNewcastle

Posted 31 March 2006 - 12:03 AM

Hey all,

The site i've been working on since September/October is almost finished now (for a University project), but have just been stumbled by the last peice of code im doing. Just wondering if any of your guys have any insight to how to fix it.

---

I have serval pages using an iFrame which im using to load a menu, im using this menu to provide some security. E.g. if roleID = 1 display links for admins to use, if roleID = 2 display links for teachers else go way (by this it loads up the denied.php file telling the user the page is resitricted.

Now my problem is that my html code for these links is interfering with the php code. Is ther anyway to get them to work together, if so how? Thanks in advance!

  <?php    
 if ($roleID ==2){
     
         
        <a href="excel.php" target="_parent">Download Database</a>
           <a href="urlenter.php" target="_parent">URL Page</a>
        <a href="admin.php" target="_parent">CP Home </a>
        <a href="Teacher_creation.php" target="_parent">Admin/Teacher Creation </a>
        Account Removal
    
} elseif ($roleID ==1) {
         <a href="../excel.php" target="_parent">Download Database</a>
}    else {

        header("Location: denied.php");
        exit;
};?>



#2 realjumper

realjumper
  • Members
  • PipPipPip
  • Advanced Member
  • 399 posts

Posted 31 March 2006 - 12:10 AM

You'd be wanting to escape those html double quotes wouldn't you?

  <?php    
if ($roleID ==2){
     
         
        echo "<a href=\"excel.php\" target=\"_parent\">Download Database</a>";
        echo "<a href=\"urlenter.php\" target=\"_parent\">URL Page</a>";
        echo "<a href=\"admin.php" target=\"_parent\">CP Home </a>";
        echo "<a href=\"Teacher_creation.php\" target=\"_parent\">Admin/Teacher Creation </a>";
        echo "Account Removal";
    
} elseif ($roleID ==1) {
        echo " <a href=\"../excel.php\" target=\"_parent\">Download Database</a>";
}    else {

        header("Location: denied.php");
        exit;
};?>


#3 olliee

olliee
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationNewcastle

Posted 31 March 2006 - 02:27 AM

Thank you very much!! That did the trick nicely.

#4 realjumper

realjumper
  • Members
  • PipPipPip
  • Advanced Member
  • 399 posts

Posted 31 March 2006 - 02:31 AM

You're welcome :-)

#5 olliee

olliee
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationNewcastle

Posted 31 March 2006 - 02:36 AM

I also manged to fix my other security issue as well :D, I'm off to bed now for some well earned rest. This web site is going to be the death of me.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users