Approach on how to create a multipage website with PHP - MYSQL custom admin panel

Hi guys,

I’m just wondering on how it’s the best practise to create a website that has multipages and where the customer can add new more pages to their website.
It’s just that, for onepage templates, it’s easy to create the sections you want them to use, and then user just need to fill up contents, but what’s the best practise on how to create new website pages, for example like wordpress?
For instance, should I use the approach to create new file on webserver?! But this leads to a question of security, as the webserver has to offer the complete access to files and folders, which is a bit unsecure…
Can someone point me some other ways to accomplish this?
Thank you so much.

Best regards.

It really depends on what you’re trying to achieve. Maybe easiest way is to install WordPress and use a combination of theme and plugins which fits your needs.

Not sure what you actually mean by that. Any website runs on a webserver.

You can set folders to be read-only, no security risks at all.

It really depends on your goals
I would suggest picking up a PHP Framework (I personally recommend Laravel) and create what you need. It will be the best choice.
Try explaining more detailed what you’re trying to achieve and maybe better to ask on dev forums, such as stackoverflow.

Hi @DrunkPixelThemes,

Thanks for your reply.
So what I am trying to do, it to create a php/mysql website script with admin panel.
So the main goal here, is to create new pages, and display them as a multipage website, and not like a onepage website.
For example, this was the last script we’ve created, and in case you want to take a look, give it a try.
Login: admin
Password: admin
So this example, only lets you to create and add content, that will be displayed as a one page (same page). What I want to do is to let users to create new pages that changed the structure from for example:
http://yourwebsite/#contact (onepage), to http://yourwebsite/contact (multipage).
I know how wordpress works, and I know it manages to store each new page on a variable from wp-posts, and this is my question all about. Should I create the file directly on server (for example by using $myfile = fopen(“testfile.txt”, “w”);), or should i create and store information on a variable, and then return it on a page? If this is the solution, how can I manage to create that page, and make users to navigate into new blank pages with that variable stored information?
Thanks :wink:

The standard way to do this is to store page data in the database, have a single index.php file, and then use an .htaccess rewrite rule to send all non-static traffic to that index.php file. The index.php file, then, looks at the URL to find what page is being requested, gets necessary data from the database, and outputs it.

Since your project involves a lot of static HTML filled with user content, I would actually suggest you use something like Twig in your script (if you’re not already). This will make the index.php option a lot easier. If you do this, use Twig v1.x to keep the minimum PHP version low.

Writing files ~

I don’t recommend creating the files on the server, because you’ll run into issues with some servers not giving PHP file-writing permissions. This of course can be fixed by changing the chmod but that’s very insecure and should never be recommended to customers on shared or reseller hosting. :slight_smile:

Nginx ~

That said, you may also run into an issue with my first suggestion: not everyone uses Apache. While nginx users are decently rare (I’ve only encountered a handful), you should still be prepared for them and have nginx configuration ready. Otherwise add Apache to your requirements.

Feel free to PM me if you have questions. :+1:


Thanks @baileyherbert! You are awesome and always a great help!
I don’t use Twig, as I’m trying to figure out on how can I create that sort loop cycle like wordpress has.

Best regards.

Oh, clear now
You should store pages in the database, as @baileyherbert said
I really recommend using a php framework for this, it will get your job done pretty quick
Good luck !

1 Like

Thanks @DrunkPixelThemes.

Well, I’m more concerned about using framework, on the time that will be takne to know how to work with it.
Although I know the MVC convention, I don’t really like the fact that these are very modular, and the wayt to point to a file has to be taken by having a lot of steps… and I just don’t feel confortable… but I also know that this is the way the future will be.
But also, as I’m trying to figure on how to make these features work, by myself, it’s also a way that I’m implementing my own MVC. :smiley:

Best regards.