Category Archives: Functionality

Make a div stick to top when scrolled to

There are times when you would want to display a bar at the top of the page when user scrolls on the page and it should go back to its original position when the user scrolls back up. This is particularly useful when you want to add say a share bar, a search bar, etc and make it always visible even when the user is at the bottom of the page.
Read more »

404 Error Page Best Practices

A 404 error page is the page that the user may reach due to various reasons. Some of the reasons are:

  • The user has entered / spelt the URL incorrectly.
  • The page has been moved or deleted.
  • The URL they clicked on was incomplete or cut in an email or message.

Read more »

Getting real client IP address in PHP

Many times we need the visitor’s ipaddress for validation, security, spam prevention, etc. Getting the Visitor’s ipaddress is very easy in PHP.

The simplest way to get the visitor’s/client’s ipaddress is using the $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables. The variable in the $_SERVER array are created by the web server (like apache) and we can use them in PHP.

// Get the client ip address
$ipaddress = $_SERVER['REMOTE_ADDR']

Read more »

Voting Functionality in a website

In this post I will give the step by step explanation of how we can add Voting Functionality to a website. At the end of this article we will have a working sample voting application. The source code for the sample voting application can be downloaded from here.

We will be using PHP, MySQL, jQuery, HTML, CSS, AJAX to implement this.

To setup this functionality we will have to first setup database, then a front-end and also a page which would actually record and retrieve the votes.
Read more »