How to check if current page is homepage

How to check if current page is homepage

In Magento sometimes we need to find out if current page is homepage or not, for some condition. So in this tutorial I will show you how to check if current page is homepage or not. If you are in template/page/html/header.phtml template file, then you can check for homepage with the following code: If you are in any other .phtml template file or in any other .php class file then …

Continue reading

How to Handle Fatal Error in PHP

How to Handle Fatal Error in PHP

Sometimes in development we see fatal errors and warnings.  Fatal error halts the execution of the page. So in this tutorial I will show you how to handle fatal error in PHP. In the below example I forced to display Fatal Error: If the file ‘another-file.php‘ is not exists you will see fatal error and warnings like below. Warning: require(another-file.php) [function.require]: failed to open stream: No such file or directory …

Continue reading

Load Data While Page Scroll with jQuery

Load Data While Page Scroll with jQuery

Now a days data load while page scroll technique is mostly used by most of successful websites like Facebook, Google and Twitter. While you scroll down the page loads more and more data, using Ajax request this is called infinity scroll. So, Today I am going to show you how to load data while page scroll with jQuery and PHP using jQuery’s plugin. There are some jQuery method available to …

Continue reading

Add to Favorite using JavaScript

Add to Favorite using JavaScript

Bookmark feature of the browser is very useful, when we need that page in future. Sometimes we found an important web pages, that might be useful in future, so we used to bookmark this on the browser. So today in this article I am showing you how to add to favorite using JavaScript. To add to favorite I have created a JavaScript function addToFavorite() as follow: In some cases the …

Continue reading

Import CSV data to table with PHP

Import CSV data to table with PHP

As Import and Export is an important functionality of a website and we have already discussed about how to Export data to CSV file in php. So in this tutorial I will show you how to import CSV data to table with PHP. First we need to read the CSV file using fopen function like below: Now to get row from CSV file we need to use fgetcsv function like below: …

Continue reading

Export data to CSV file in php

Export data to CSV file in php

In many website’s admin section, import/export functionality is required, so you can get and update the records quickly as per your requirement. So today in this tutorial I will show you how to export data to CSV file in php. You can use following code as it is if you want to export a table, you just need to change the database and table name. This is a simple program …

Continue reading

Convert an email into link from text in PHP

Convert an email into link from text in PHP

In some websites, when we add comment with email then email automatically converts into a link, So today I am showing you how to convert an email into link from text in PHP. As ereg_replace() is deprecated in PHP 5.3 you should use preg_replace like below: Now you can use above function like below: And output will be:

Remember me feature using cookies in PHP

Remember me feature using cookies in PHP

Remember me feature is used with the login form to store username and password using cookies, so the form gets auto filled with these when we get the form on browser. So, Today I am going explain how to use Remember me feature using cookies in PHP. First add a remember me checkbox to your login form like below: Now add following code to your login function after user submits …

Continue reading