Trium918 Posted April 14, 2007 Share Posted April 14, 2007 Would this be a good structure of a website? <? function do_html_header($title) { // print an HTML header ?> <html> <head> <title><?=$title?></title> <style> body { font-family: Arial, Helvetica, sans-serif; font-size: 13px } li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px } hr { color: #3333cc; width=300; text-align=left} a { color: #000000 } </style> </head> <body> <img src="bookmark.gif" alt="PHPbookmark logo" border=0 align=left valign=bottom height = 55 width = 57> <h1> PHPbookmark</h1> <hr> <? if($title) do_html_heading($title); } function do_html_footer() { // print an HTML footer ?> </body> </html> <? } function do_html_heading($heading) { // print heading ?> <h2><?=$heading?></h2> <? } function do_html_URL($url, $name) { // output URL as link and br ?> <br><a href="<?=$url?>"><?=$name?></a><br> <? } ?> Link to comment https://forums.phpfreaks.com/topic/47005-build-user-authentication-part3/ Share on other sites More sharing options...
Glyde Posted April 14, 2007 Share Posted April 14, 2007 Personally, it's my little rule of thumb to never have HTML integrated within PHP. I always always always use templates. It is much easier to work with, much easier to edit, and it makes your PHP files so much easier to look at. This function (with the help of a parent class) will generate an entire page, and format tons of messages, without a single piece of HTML ever being including in the script. Additionally, the language items (basically any text that is output) comes from another file so it's easy to translate the entire site. <?php function loadPosts() { $this->dbox->template->fromFile("index.xml"); // Load the messages if ($this->dbox->loadBoxMessages(1)) { $j = 1; // Loop through the list of messages foreach ($this->dbox->boxMessages as $key=>$messageItem) { // Display 'me' if the current user sent it if ($messageItem['u_id'] == $this->dbox->user->userData['u_id']) $messageFrom = $this->dbox->lang['U_ME']; else $messageFrom = $messageItem['u_user'] ? $messageItem['u_user'] : $messageItem['p_user']; // Setup variables and display the post $this->dbox->template->addVar("post", "j", abs(($j % 2) - 2)); $this->dbox->template->addVar("post", "modTools", $this->dbox->user->userData['u_type'] > 0 ? true : false); $this->dbox->template->addVar("post", "date", strtolower(date("M jS Y h:i:s a", $messageItem['p_date']))); $this->dbox->template->addVar("post", "uname", $messageFrom); $this->dbox->template->addVar("post", "text", $messageItem['p_text']); $this->dbox->template->addVar("post", "id", $messageItem['p_id']); $this->dbox->output .= $this->dbox->template->displayRendered("post"); $j++; } } else { // No messages, display an error $this->boxError("E_NO_POSTS"); } } ?> That's just a general rule I use. Link to comment https://forums.phpfreaks.com/topic/47005-build-user-authentication-part3/#findComment-229277 Share on other sites More sharing options...
Trium918 Posted April 14, 2007 Author Share Posted April 14, 2007 Anymore ideas? Link to comment https://forums.phpfreaks.com/topic/47005-build-user-authentication-part3/#findComment-229330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.