Rommeo Posted December 8, 2009 Share Posted December 8, 2009 For our semester project as a group we're building an advertisement website. it's simply ; "visitors can see any advertisement like home/automobile advertisement visitors that are logged in can send messages to other users and post a new advertisement" it's like very simple version of e-bay.com And my problem is; In my UML i have 3 classes [Page] <---(connected to)---[Advertisement]<---(connected to)---[Guest] -When guest is logged in, he can send ads, otherwise latest ads will be listed. 1) Is this the way of thinking is correct ? Can it be done with this 3 classes ? Are my classes correct ? 2) Cause my page will change when the user is logged in ( ex : messages will be shown when logged in ) I was using a lot of echos and ifs like if ( user is logged in ) show_messages () else display_login_form() . . public function display_login_form() { echo "<form name = "" action = "".... } As a result I m really tired of correcting and adding " " tags to every html code. So my question is can I display forms or files by include or require method ? like // show messages table "messages.php file" require it when needed. <table width="400" border="1"> <tr> <td>Hello $this->username</td> <td>You have $this->messagecount messages</td> ........ So in my page class I can just require or include the specific file instead of echoing the table or codes. Is it possible ? Thank you in advance for your help. Quote Link to comment https://forums.phpfreaks.com/topic/184432-classes/ Share on other sites More sharing options...
Rommeo Posted December 9, 2009 Author Share Posted December 9, 2009 Any ideas ? Quote Link to comment https://forums.phpfreaks.com/topic/184432-classes/#findComment-973881 Share on other sites More sharing options...
forumforme123 Posted December 9, 2009 Share Posted December 9, 2009 why not write your classes in php files, and include them in your html layout (.php) files? Quote Link to comment https://forums.phpfreaks.com/topic/184432-classes/#findComment-973926 Share on other sites More sharing options...
oni-kun Posted December 9, 2009 Share Posted December 9, 2009 Any ideas ? Are you able to instantiate and use sessions? That will fix your problem with the login form. What I'd recommend is sending them to a login page if say, $_SESSION['user_id'] is not set, And you don't need to write public functions to echo a form, it's a waste of server processing time than to just fit it in an IF statement. And yes, you can include/require any file of PHP or HTML to set up a more simple template system. Quote Link to comment https://forums.phpfreaks.com/topic/184432-classes/#findComment-973929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.