by Kev on 9 February, 2009
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
When you’re creating a website with lots of pages all using the same look and feel, headers, CSS etc, it obviously makes sense to create a simple template.
Begin by creating a page in XHTML/HTML that looks and works exactly as you wish. Now cut and paste the header into a new file and put it into a folder called /includes/ on your server. This should be saved as something like header.php. Don’t worry that it’s not actually PHP code, that doesn’t matter. Do the same thing for your main navigation (the navigation that will remain the same throughout). You could put that in header.php but I like to keep it separate just in case there are rare cases where the navigation isn’t needed on a particular page. If you have subnavigation that changes section by section isolate that and put it in its own php file and finally, do the same thing for your footer. [click to continue…]
Use Facebook to Comment on this Post
by Kev on 16 October, 2008
Let’s say that you want to add a file upload facility to your website via PHP. The key to this is to ensure that the permissions on the folder you are copying up to allow PHP to do the copying. This is a classic Gotcha that can waste a whole load of time.
The first thing you need to know is that the folder you’re copying up to must be “Owned” by “Apache” rather than the site owner. In other words, you need to set the permissions on the folder to be owned by Apache. This then leads onto the other question “what is the Apache OwnerID?”.
I spent a good couple of hours trying to find an answer to this question. The owner Id can be found in the configuration files but a MUCH easier way is to create a PHP file containing the line:
<?php
 echo phpinfo();
?>
Run this file in your browser, scroll down to the “apache2handler” section and you’ll see “User/Group” listed. The numbers next to this show first the OwnerId and then the GroupId (usually both the same). Use a tool such as BitVise Tunnelier to log into your web server and set the Owner and Group to this number and PHP will then be able to copy to that folder. Take care only to change ownership of those folders you specifically want to be able to upload files to.
Use Facebook to Comment on this Post