Skip to main content

Posts

Showing posts from May, 2008

New Working Method of Making Blogger Title Tags SEO Friendly

[ Blogger made some recent changes on 9th May 2008 which enables us to use a simple method to make SEO Friendly Title Tags for Post Pages (Permalink Pages), I guess I am a bit too late to notice but as we’re discussing about Web Programming lately, I’ll share the method anyway. ] One of the biggest problems I face with Blogger blogs is the inability to create custom SEO and human friendly title tags. Blogger does not give us any option to change the way title tags are in post pages. Titles of post pages in Blogger are always in the following form: [Blog Title] : [Post Title] In this case when you have a bit long Blog Name, all your pages in the Search Engine index would start with the blog name taking most of the previous space. That way it wouldn’t be relevant to the content of the post in most cases The following form of title would be considered good: [Post Title] : [Blog Title] Or if your blog’s name is too long you can use jus...

Creating a Simple Poll Script in PHP

OK, so again a useful script that we are going to create here. A polling system/script needs no introduction as it has been on the Web since long and is a good method to increase visitor activity on a website, apart from knowing their responses. OK let’s start! A polling system requires vote data to be stored, for that database (MySQL) would be the best choice. Possible table structure for the database for a poll having three options would be Logically thinking we know that only one row is required for a poll. Each time someone votes the value of the respective fields should be updated (incremented). Initially the table would be like below: After five votes to the first option, four to the second option and one to the third; the table would look like: It should now be clear why we only need one row for a poll. Designing the Poll OK, now we’ll have to design the poll using an HTML table, some radio buttons and a submit button. You may wri...

Constructors & Destructors of a Class in PHP

[ Please read Introduction to Classes in C++ , Introduction to Constructor and Destructor Functions in C++ and Destructor Functions in (C++) in Detail to know more about Constructors and Destructors, even though from C++’s perspective, they are useful nonetheless. ] Constructors A constructor is a special member function of a class which is called automatically when an object of the class is created. We can use it to perform useful initialization such as giving initial values to member variables etc. Unlike C++, PHP’s constructors always have the name ‘__construct’ and they can be defined as:     function  __construct ()     {         ...     } Prior to PHP Version 5, constructors used to have the same name as of the class (like in C++). Though PHP5 still understands constructors defined this way to be backward c...

Object Oriented PHP...Creating and Using Classes

[ Please Read Introduction to Classes in C++ , Unit Conversion Program using Classes , A Multi-Purpose String Class in C++ etc. for more information. Despite being from C++'s perspective they're useful. ] In PHP a class is defined as following: class  myclass {     ...     ... } For C/C++ programmers, do note that there’s no ‘;’ after the closing curly brace. A variable can be defined inside a class (AKA member variable) as: class  myclass {      //notice the use of 'var'      var  $var ;     ...     ... } NOTE: We have to use ‘var’ keyword to define variables. A function can also be defined inside a class as following. These functions are known as Member Functions. class  myclass {     function  m...

A Complete Note Keeping Application

In this post we are going to expand the Note Keeping Application , using MySQL to create a complete multi-user Application which would be able to register new users as well. It’d be a multi-user system hence many users can register and work on their notes simultaneously. Each user’s data will be private to them. It’d also have the missing features such as editing and deleting of existing notes, hence a complete Note Keeping Application. In a multi-user application we need to separate each user’s data so that every user is shown only the data belonging to them. As we’ll be using MySQL database to store data, one option is to create a table for each user, it’d be good but when you have like thousands of users, having a table for each is not very efficient. There is one very efficient technique however, to separate data of different users using relational database structure. For this we’ll only need two tabl...

Using Template System for CSS Designed Web Page

In the last post on Creating Simple Template Based Website we designed a simple Template System, if you remember its layout was designed using a Table. While tables can be used to design page layout, it’s not the standard way and has got many problems associated, instead Cascading Style Sheets or CSS should be used. If at all I’m going to give an introduction to CSS now, I’d say it is a way of styling pages and page elements. Even if you don’t know about CSS (and I’m not discussing much about it here) you’ll understand this post and how CSS can be used for designing page layout. So let’s begin! Below is the CSS coded version of the web page that we deigned in the previous post: <html> <head> <title>CSS Coded Web Page</title> <style> #page{     width: 90%;     height: 90%;     border: 1px so...

Using 'require' to Create a Simple Template System for Websites

The image above shows what different parts of a general website are known as. It is certain that for most websites (even this one), there is a consistent look. E.g. the header, sidebar and footer remain the same for all the pages of a website such that you may create many pages from one page just by changing the body text and saving as a different file. But suppose if you have created, like 10, 20, 30, 50 or even more pages that way and now you want to change the copyright year on the footer or add a link on the sidebar, what would you do? There is only one way, to change all the pages which is very cumbersome. Well, PHP has got features to include consistent parts of pages on many pages such that editing only that part at one place would be enough to change the whole site. It can be done in the simplest way as following: <html> <head> <title>Sample Page</title> </head> <body> <?php require( ...