Create dynamic pages[NOT SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Create dynamic pages[NOT SOLVED]

Post by bagi »

Hi all, I need to create php page (if u have best way, write) which will show another content depending on a request. For example, site.com/account and site.com/account?settings must show another pages (with significant differences!). What is a best way to solve this problem? I need to create ramification with setting request and with no this?
Last edited by bagi on Fri Nov 01, 2013 1:52 pm, edited 1 time in total.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Create dynamic pages

Post by Celauran »

Sounds like you want a front controller to capture all incoming requests and then route them as needed.
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Re: Create dynamic pages

Post by bagi »

Yes, but I don't understand it on my example.
If i have a request I need to create a ramification witch will handle that?

For example

Code: Select all

if($command == "showProfile"){/*showing a profile*/}
else if($command == "saveSettings")//now we saving inputted settings
and ect. I right understood this approach?
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Re: Create dynamic pages

Post by bagi »

And is a good way to store all functions in one php file and include that in each file?
rhecker
Forum Contributor
Posts: 178
Joined: Fri Jul 11, 2008 5:49 pm

Re: Create dynamic pages[NOT SOLVED]

Post by rhecker »

Code: Select all

switch ($_GET['command']){
case 'showProfile':
include('profile.php');
break;
case 'saveSettings':
include('savesettings.php');
break;
}
I used include files in the example above, but it could also be a query, a variable, or whatever, and any combination thereof.

. . .and sometimes it makes sense to store all functions in one php file, unless it will load a lot of unneeded code in some pages.
Post Reply