Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 701955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:40:02+00:00 2026-05-14T03:40:02+00:00

I’m creating a kind of massive network for users to register and login. I

  • 0

I’m creating a kind of massive network for users to register and login. I want to try using classes, but I’ve never used them (expect some mysql-wrappers etc). Could you provide some tips and sample-structure for my project?

The idea is to simply have a index.php, which prints the whole page and does all the action. Index.php calls functions from classes inside other files.

I need:

  • user-class for checking if logged in and retrieving user-info
  • different kind of “page”-classes for functions needed in those pages

I’m not asking for full code, but just a start. I don’t know, how to use public functions or anything like that. How to wrap these classes to work together? So no functions, just the structure!

Martti Laine

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:40:02+00:00Added an answer on May 14, 2026 at 3:40 am

    Well for the first part, I’ll give you hint on using the index for everything. I use a switch statement that simply calls out everything, like so:

    <?php
    
    
    switch($_REQUEST['mode']){
    
        case 'create':
            $ourhtml = $object->do_create();
        break;
    
        case 'read':
            $ourhtml = $object->do_read();
        break;
    
        case 'update':
            $ourhtml = $object->do_update();
        break;
    
        case 'delete':
            $ourhtml = $object->do_delete();
        break;
    
        default:
    
        $ourhtml = "<form action=\"index.php\" method=\"get\">
        <input type=\"text\" name=\"name\"> 
        <input type=\"hidden\" name=\"mode\" value=\"create\">
        <input type=\"submit\" value=\"create new\">
        </form>";
    
        <?php
    
        break;
    
        }
    
        echo $ourhtml;
    
    ?>
    

    This code by itself does nothing, but it gives you a general idea of how you can switch between many different “pages” using just index. Adding a new page is as simple as adding another case to your switch statement.

    As far as structure goes, I would really recommend you do some reading on MVC. It might seem complicated at first, but once you get the hang of it, it will save you a lot of time and trouble. Here are some good reads on it:

    http://nemetral.net/2008/07/31/a-gentle-introduction-to-mvc-part-1/

    http://www.phpro.org/tutorials/Model-View-Controller-MVC.html

    Also, for general class structure, nothing beats php.net’s explanation of it:

    Classes and Objects

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
I am using JSon response to parse title,date content and thumbnail images and place
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.