Welcome Guest, Not a member yet? Register   Sign In
How to create Controller & view pages for each user?
#1

By using fwrite I know how to create pages and the contents but to create a Controller for an user I need to do a backspace \b to delete the last curly bracket } and that wont work in PHP fwrite.

Does anybody know how else that can be done?

I'm considering using Python but will create another post for that subject.
Reply
#2

What unique stuff are you doing for creating a controller for each user? Can't think of any scenario you will need one.
Reply
#3

(01-18-2020, 03:55 PM)jreklund Wrote: What unique stuff are you doing for creating a controller for each user? Can't think of any scenario you will need one.

Please tell me how you would achieve the same?
Reply
#4

(This post was last modified: 01-19-2020, 04:23 AM by christaliise.)

(01-18-2020, 03:55 PM)jreklund Wrote: What unique stuff are you doing for creating a controller for each user? Can't think of any scenario you will need one.

For each User I want to record
(1) Profile
(2) Family
(3) Businesses
(4) Adverts
(5) Friends
(6) Relationships with other Users
(7) Assets
(8) Accounts
(9) Miscellaneous

The only other way I can think of is to extract from the database by session but I want to record the past and present of every transaction.

So I think having separate Controller & view pages would be the only way to achieve that.

But I need to do a backspace \b in PHP.
Reply
#5

That's what databases are for. You save their past and present in the database. And create a generic Controller for Accounts and fetches their unique data from the database (based on userid, from session). Never create 1000 Account files for all your users.
Reply
#6

(01-19-2020, 05:11 AM)jreklund Wrote: That's what databases are for. You save their past and present in the database. And create a generic Controller for Accounts and fetches their unique data from the database (based on userid, from session). Never create 1000 Account files for all your users.

Firstly, I find databases very complicated and I've avoided using it too much. I have a database that stores the registration of each user, however there is an upload file created for each user's documents.

If I was to use a database for storing past activity it would mean double handling from present to past when something changes. But if I use Controller & view pages each transaction will be recorded once.

I know nothing about "creating a generic Controller for Accounts and fetches their unique data from the database" however my system will fetch basic information with userid & session from the database.

My system will have far more that 1,000 account files for all the users. But I just need to learn how to delete the last curly bracket } from the Controller each time an user registers.
Reply
#7

(01-19-2020, 08:01 AM)christaliise Wrote: My system will have far more that 1,000 account files for all the users. But I just need to learn how to delete the last curly bracket } from the Controller each time an user registers.

No, you need to learn how to properly develop a web application.

If you continue with your idea of generating 1000 controllers for your 1000 users, you will end up with an unmaintainable mess that won't work half of the time. Start by creating something simple with a tutorial, then rewrite your current app the proper way, with a database.

Good luck!
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#8

(This post was last modified: 01-19-2020, 11:10 AM by christaliise.)

(01-19-2020, 08:31 AM)includebeer Wrote:
(01-19-2020, 08:01 AM)christaliise Wrote: My system will have far more that 1,000 account files for all the users. But I just need to learn how to delete the last curly bracket } from the Controller each time an user registers.

No, you need to learn how to properly develop a web application.

If you continue with your idea of generating 1000 controllers for your 1000 users, you will end up with an unmaintainable mess that won't work half of the time. Start by creating something simple with a tutorial, then rewrite your current app the proper way, with a database.

Good luck!

@includebeer I like constructive criticism but comments like "need to learn how to properly develop a web application" - "you will end up with an unmaintainable mess" - "start by creating something simple with a tutorial" - "rewrite your current app the proper way" are not constructive. You could have been more elaborate in your comments which would be constructive.

As I've said using a database can be double handling when some information changes. For example if a user changes a street address, the old address will need to be transferred to a different field and with a date, so that the new address can be inserted. None of that mess would occur with a Controller & view page being created only once.
Reply
#9

It all depends on how you design your database. What are you storing the old adress for? Invoices? If so store the address in the invoice table (of the database).

The current address only need to be stored once. On the users profile. With your current design you will have X* controllers. And will need to rewrite your controller Y** times when you change some data.

By the looks of things you want to append every single user inside one files. If you do so, you won't be able to even look up a user less change out any information about said user. As you can't replace and find things.

* user accounts.
** every time you change relation (to other users), their adress etc.
Reply
#10

(This post was last modified: 01-19-2020, 02:20 PM by includebeer.)

What can I say? We all tell you that you need to use a database and generate your profile page dynamically with the data retrieved from the database. But you say “No, it’s too complicated” and you want to create 1000 files. I’m telling you it’s not a good idea. You will end up with a whole lot of problems. But if you still want to do it that way, it’s up to you.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB