Jump to content

Classes


Rommeo

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.