Jump to content

Recommended Posts

Posted

I just began my approach on learning PHP and MySQL. I recently just created my first database, username, blah via cpanel and still messing around with it. I've seen alot of sites that network all their links via php.

 

Sometimes I see links on sites that look like this:

http://www.addresshere.com?index.php?files=link

 

How do designers/webmasters organize their sites so that links tend to direct like that? Is it using databases with MySQL or what?

Posted

Not necessarily, but possibly. On one of my sites I have the framework, links, headers, etc all in one php file named index.php. In that, at the appropriate place I have a statement in PHP coding that says to include the contents of a file named in the variable FILE. This lets me have just the interior content of a page in a file named aboutus.htm and the framework is in only one file instead of 70. On my links I just enter mytchsite.com/index.php?file=aboutus.htm and I get the framework from index.php and the "guts" of the site from the small file aboutus.htm

 

If it is a catalog type site then they can do the same thing but the photos of the items and the descriptions are usually in mySQL databases instead of separate files.

Posted
Not necessarily, but possibly.  On one of my sites I have the framework, links, headers, etc all in one php file named index.php.  In that, at the appropriate place I have a statement in PHP coding that says to include the contents of a file named in the variable FILE.  This lets me have just the interior content of a page in a file named aboutus.htm and the framework is in only one file instead of 70.  On my links I just enter mytchsite.com/index.php?file=aboutus.htm and I get the framework from index.php and the "guts" of the site from the small file aboutus.htm

 

If it is a catalog type site then they can do the same thing but the photos of the items and the descriptions are usually in mySQL databases instead of separate files.

 

 

 

I see. I'm interested in how you do that. How do you just have 1 index page and have external information come from just putting ?file=blahblah at the end of a link? I'm very curious and I want to start organizing my websites like that.

Posted (edited)

In my post I mentioned that the article was a little basic. But I liked the fact that it seemed to be built on sound principles. I see a lot of people that are learning PHP discover a new tool but aren't told how to use it safely and to take steps that would prevent attacks.

 

The article doesn't address some obvious things you'd want in a templating system, as you have pointed out.

 

To answer your question, there are several ways to skin a cat. I would put the html from the 'main' file (in the tutorial referenced) into the header file. This way you could do something like

><title><? echo $site_title; ?></title>

 

How you set the site_title variable just depends on your coding style and what you're comfortable with. I'd probably take the simple array given in the tutorial and turn it into a more detailed associative array where the title was contained in the array.

 

But, in all honesty, I wouldn't use this templating system as it's written. It's a good starting point for you to learn how to build templating systems. Specifically, it defines in advance a finite number of possibilities for the PHP to include into the code. This is a safety feature that is missing from templates built by beginners.

Edited by surefire
Posted
In my post I mentioned that the article was a little basic.  But I liked the fact that it seemed to be built on sound principles.  I see a lot of people that are learning PHP discover a new tool but aren't told how to use it safely and to take steps that would prevent attacks.

 

The article doesn't address some obvious things you'd want in a templating system, as you have pointed out.

 

To answer your question, there are several ways to skin a cat.  I would put the html from the 'main' file (in the tutorial referenced) into the header file.  This way you could do something like

><title><? echo $site_title; ?></title>

 

How you set the site_title variable just depends on your coding style and what you're comfortable with.  I'd probably take the simple array given in the tutorial and turn it into a more detailed associative array where the title was contained in the array.

 

But, in all honesty, I wouldn't use this templating system as it's written.  It's a good starting point for you to learn how to build templating systems.  Specifically, it defines in advance a finite number of possibilities for the PHP to include into the code.  This is a safety feature that is missing from templates built by beginners.

 

 

 

 

 

do you know of anymore tutorial sites / walkthrough guides like the first one you gave out . im interested to see how the same concept can be "skinned.." and maybe help me understand the concept more

Posted

I hate to sound nasty but it sounds like they have tried to run before learning to walk. You should learn more about the basics of PHP (includes, variables, GPC etc) before starting on MySQL. A good solid base is a must for anything.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...