Skip to main content
Inspiring
May 23, 2008 4:40 PM UTC
Answered

Content include on $p var VS. seperate pages

I am just starting a new site ( www.freecrm.zymichost.com in php with back end MySQL data

I have been advised that you should only have one main index.php file and then include main content based on the variable posted.

e.g.

if $p == "Register" then link /index.php?p=Register
elseif $p=="Login" then link /index.php?p=Login
else link /index.php?Home

blah de blah - you get the message.

The page I have has a header, main content and footer include - all of which work great but I am having doubts that further down the line, I will start to get problems with passing additional variables.

Is this method recommended or should I create standard seperate pages based on a template?

In addition, I have a "sniffer" script, which captures visitor data and will, eventually, insert those details into a history database. This will then be viewable by potentail advertisers to validate visitor count.

My problem with this is that if I use the first method of content include, I will have to capture the variable extension (i.e. after ?p=blah&cusid=1456374) to obtain which page is visited but it will also capture more personal information passed in the URL (such as cusid...)

Again, I think that if I create sepearate pages, I can leave out the variable capture from the URL.

Does any of this make sense?

Any opinions would be greatly appreciated.
This topic is closed to new replies. Start a new post to keep the conversation going.
Newsgroup_UserCorrect answer
Inspiring
May 24, 2008 8:45 AM UTC
.oO(RichardODreamweaver)

>I am just starting a new site ( http://www.freecrm.zymichost.com in php with
>back end MySQL data
>
> I have been advised that you should only have one main index.php file and then
>include main content based on the variable posted.

It's one possible way, but definitely not the only one. So IMHO it's a
rather bad advice.

> e.g.
>
> if $p == "Register" then link /index.php?p=Register
> elseif $p=="Login" then link /index.php?p=Login
> else link /index.php?Home

And bad code too. If you want to go that route, use a lookup table.

> blah de blah - you get the message.
>
> The page I have has a header, main content and footer include - all of which
>work great but I am having doubts that further down the line, I will start to
>get problems with passing additional variables.
>
> Is this method recommended or should I create standard seperate pages based on
>a template?

I would not recommend it unless you know exactly what you're doing. It
can make maintenance more complicated and leads to really ugly and user-
unfriendly URLs. You don't want that.

Additionally you won't get proper access statistics from such a setup,
because for a logfile analyzer there's only one page.

Both problems can be solved, but that requires even more work. So for
now separate pages would be the better choice.

Micha

3 replies

Inspiring
May 24, 2008 9:08 PM UTC
.oO(RichardODreamweaver)

>Micha - thank you - this confirms what I thought and I'm glad I haven't
>gone further down this route.
>
>As you have supplied valuable advise before, I will follow it now...
>
>Here's to seperates!

You're welcome.

Micha
Translate
Inspiring
May 24, 2008 7:05 PM UTC
Micha - thank you - this confirms what I thought and I'm glad I haven't gone further down this route.

As you have supplied valuable advise before, I will follow it now...

Here's to seperates!
Translate
Newsgroup_UserCorrect answer
Inspiring
May 24, 2008 8:45 AM UTC
.oO(RichardODreamweaver)

>I am just starting a new site ( http://www.freecrm.zymichost.com in php with
>back end MySQL data
>
> I have been advised that you should only have one main index.php file and then
>include main content based on the variable posted.

It's one possible way, but definitely not the only one. So IMHO it's a
rather bad advice.

> e.g.
>
> if $p == "Register" then link /index.php?p=Register
> elseif $p=="Login" then link /index.php?p=Login
> else link /index.php?Home

And bad code too. If you want to go that route, use a lookup table.

> blah de blah - you get the message.
>
> The page I have has a header, main content and footer include - all of which
>work great but I am having doubts that further down the line, I will start to
>get problems with passing additional variables.
>
> Is this method recommended or should I create standard seperate pages based on
>a template?

I would not recommend it unless you know exactly what you're doing. It
can make maintenance more complicated and leads to really ugly and user-
unfriendly URLs. You don't want that.

Additionally you won't get proper access statistics from such a setup,
because for a logfile analyzer there's only one page.

Both problems can be solved, but that requires even more work. So for
now separate pages would be the better choice.

Micha
Translate