Skip to main content

Posts

Login with LinkedIn using PHP

Linkedin is one of the most popular social networks with the huge user base. Like the Facebook , Twitter and Google authentication, LinkedIn also is used for the user authentication in the website. If you want to allow your website’s user to login with the social account, LinkedIn login needs to be added. LinkedIn provides various API to integrate user login system in the website. Using LinkedIn API you can let the user login to your website with their LinkedIn account. In this tutorial, we will show you how to integrate user Login System with LinkedIn using PHP . The login with LinkedIn feature helps the user to sign into your website with their LinkedIn account without registration on your website. Our LinkedIn login API tutorial provides you an easy way to build user login system with LinkedIn using PHP and store the user profile data into the MySQL database. We’ll use OAuth library to connect with LinkedIn and build LinkedIn login system in PHP . Before you get started to int...

CodeIgniter Redirect to Current Page URL After Logout ?

In CodeIgniter you can get current page URL using CodeIgniter URL helper function current_url() . Now you knew how to get current page url, then append the current page url to logout url, here is the code echo anchor('auth/logout','logout/'.base64_encode(current_url())); now in your logout method should be something like this : public function logout($url){ redirect(base64_decode($url)); } I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

How to Export Data to CSV File using PHP and MySQL

CSV (comma-separated values) is the most popular file format to store tabular data in plain text. Generally, CSV file is used to import and export data for moving tabular data between programs. Import and export data is the most used feature in the web application, and CSV file format is a best chose for that. In the earlier tutorial, we have shown How to Import CSV File Data into MySQL Database using PHP . In this tutorial, we will show you how to export data from MySQL database to CSV file using PHP . Also, you will learn to create CSV file in PHP and download and save MySQL data in CSV file using PHP. To demonstrate Export to CSV functionality, we will build an example script which will export members data from the MySQL database and save in a CSV file using PHP. Create Table in MySQL Database The following SQL creates a members table with some basic fields in MySQL database. The members table holds the member’s information which needs to be exported. CREATE TABLE `memb...

PHP : detect location of the user

Using the below function you can check the city from which the user is visiting your website. function detect_city($ip) { $default = 'UNKNOWN'; $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip); $ch = curl_init(); $curl_opt = array( CURLOPT_FOLLOWLOCATION => 1, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_USERAGENT => $curlopt_useragent, CURLOPT_URL => $url, CURLOPT_TIMEOUT => 1, CURLOPT_REFERER => 'http://' . $_SERVER['HTTP_HOST'], ); curl_setopt_array($ch, $curl_opt); $content = curl_exec($ch); if (!is_null($curl_info)) { $curl_info = curl_getinfo($ch); } curl_close($ch); if ( preg_match('{<li>City : ([^<]*)</li>}i', $content, $regs) ) { $city = $regs[1]; } if ( preg_match('{<li>State/Provinc...

Better Broken Image Handling

Missing images will either just display nothing, or display a [ ? ] style box when their source cannot be found. Instead, you may want to replace that with a "missing image" graphic that you are sure exists so there is better visual feedback that something is wrong. Or, you might want to hide it entirely. This is possible because images that a browser can't find fire off an "error" JavaScript event we can watch for. // Replace source $('img').on("error", function() { $(this).attr('src', '/images/missing.png'); }); // Or, hide them $("img").on("error", function() { $(this).hide(); }); Additionally, you may wish to trigger some kind of Ajax action to send an email to a site admin when this occurs.

Transparent Clothing Effect Photoshop Tutorial [ YouTube Embed Responsibly Example ]

Create secure login script in PHP

Recently more than 10 members asked me how to create secure login script in PHP. So in this article am going to explain you how to create a secure login system using PHP and MYSQL. This type of login system am using in most of the website, if you are using any CMS means no need of this system because CMS have inbuilt login system. In this method am mainly concentrating on the username and password strings. Am using number of steps to clear the string and prevent the any type of SQL injection to avoid the hacking. First we will start the session and connecting to the database. FInd the PHP code below, //Start session session_start(); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select...

SMS Gateway Integration in PHP

These days SMS feature is used for the various purpose in the web application. For example user authentication, OTP verification, sending the notification to users. To send SMS from PHP script you need to select a best SMS gateway provider that suitable for your requirement. Once the SMS gateway and plan selection are completed, now it’s time to integrate SMS gateway in PHP script. In this tutorial, we will show you how to integrate SMS gateway API in PHP . SMS gateway integration process is very simple and less time required. Using our example code you can easily send SMS from your website using SMS gateway API and PHP . Usually, the SMS provider provides 3 types of plan, One-way messages, Two-way messages, and Both-ways messages. One-way messaging allow you to send SMS to the customers, but Two-way messaging allow not only the send SMS but also receive a reply from the customer. Generally, SMS gateway provides a callback URL for passing some parameters, like API Key, send...

Laravel Tutorial – CRUD (Create Read Update Delete) Operations in Laravel

In our previous Laravel 5 tutorial, we have learned how to install and configure Laravel application on Windows or Ubuntu . Now you’ll learn the most used functionality in this third part of the Laravel tutorial. In this tutorial, we’ll create a simple CRUD application with Laravel 5 . Our step-by-step guide for beginners helps you to implement CRUD (Create, Read, Update, and Delete) Operations in Laravel . If you haven’t installed the Laravel application on your server, go through the Laravel installation and configuration tutorial first . Here we’ll provide the advanced functionality (fetch, add, edit, and delete) implementation guide in Laravel. For your better understanding, we’ll create an example blog post management application with Laravel 5 . CRUD Operations in Laravel 5 To demonstrate view, add, edit, and delete functionality, we’ll show the post management system in Laravel 5. This sample Laravel CRUD application has the following functionality. Retrieve posts dat...

Fetch Meta Data from URL using PHP and Ajax

In this tutorial am going to explain how to get meta data from an URL to display in website. It’s similar to URL data extracting. You can see this example most of social networking sites like Facebook and Google Plus. It also called as Extracting data from URL using Jquery, Ajax and PHP. I have used get_meta_tags PHP function to get the Meta data from URL. This is a PHP in built function. The output will be returned in array. $url=get_meta_tags("http://www.webinfopedia.com/"); This will give you an array of all Meta data like Description, Keyword, Author, Copyright, Robot etc… Now you need to display it like below. echo ($url["description"]); echo substr($url["keywords"], 0, 128); echo ($url["copyright"]); To get the title tag form URL am using file_get_contents function. echo get(file_get_contents('http://www.webinfopedia.com/'), ""); //get function function get($a,$b,$c) ...

How to Create Custom Post Types in WordPress without using Plugin

WordPress has many different content types. A single item of content is called a post, also post is a specific post type. All the post types are stored in the same database table (wp_posts) and differentiated by a column called post_type. By default, five post types are available in WordPress. Post (Post Type: ‘post’) Page (Post Type: ‘page’) Attachment (Post Type: ‘attachment’) Revision (Post Type: ‘revision’) Navigation menu (Post Type: ‘nav_menu_item’) Also, you can create new post types which are called Custom Post Types. A custom post type can be added to WordPress using register_post_type() function. It very simple and you don’t need to use any plugin for that, you can register your custom post types without using Plugin. In this article, we’ll show you how to create custom post types in WordPress. Also, you’ll know how to add taxonomy or category of custom post types in WordPress. WordPress custom post type helps you to divide up your website content in a more stru...

The Transitioning Guide of WordPress.com to Self-Hosted WordPress

WordPress is one of the most flexible and versatile blogging platforms. It is considered as an ideal blogging platform for webmasters who are seeking to build their blogs in few minutes. But if you’re a newbie then you must be confused, which way to go WordPress.com or WordPress.org. And if you’re are a regular WordPress user then you must be wondering how to switch your Blog from WordPress.com to WordPress.org. Making a switch to WordPress.org can be intimating for users who aren’t as technically inclined. Therefore, keeping this is mind here is a comprehensive guide to help amateurs understand well about WordPress.com and WordPress.org and how a webmaster can move to self-hosted WordPress. WordPress.com vs. WordPress.org A Brief Explanation to WordPress.com WordPress.com is a free self-hosted website used for commercial purpose. It runs on an open source WordPress platform, which means your website will be free forever, but the user can pay to upgrade the site to achieve the speci...

Add Featured Image to WordPress RSS Feed

In our earlier tutorial, we have shown you how to add featured image or thumbnail to WordPress post . But the featured image would not be automatically displayed in the RSS feed. A filter need to be added to display featured image in RSS feed. In this article, we’ll provide the simple way to add featured image to WordPress RSS feed. Using add_filter() with a simple function, you can easily include post thumbnail in RSS feeds. Open the theme’s function.php file and add the following code in this file. // display featured post thumbnails in WordPress rss feeds function add_post_thumbnail_in_rss_feeds($content){     global $post;     if(has_post_thumbnail($post->ID)){         $content = '<p>' . get_the_post_thumbnail($post->ID) . '</p>' . get_the_content();     }   ...

Guide to Create Custom Page Templates in WordPress

In WordPress, page templates are a specific type of template file that are used for a specific page or group of pages. A page template only applies to pages, not for other content types. The page templates are used to change the look and feel of the pages. If you want to make a page different from other pages, create a custom page template. This tutorial shows you how to create custom page templates that can be assigned to the pages from administrative panel. Custom page template allows you to make the different layout for different pages. Template Hierarchy of Page Templates in WordPress When the browser requests a page, WordPress selects which template will use to render this page. As per the WordPress Template Hierarchy, page template files are looked like the following order. Page Template – WordPress looks for a custom template assigned to the respective page. If found uses it otherwise move to the next hierarchy. page-{slug}.php – If a custom template is not found, Word...

Why Should You Add Front-end Login Page in WordPress and How

Sending your WordPress website users to the default login page is fine when you’re running a site with just a handful of users. But, in case you’re running a membership site or other sites with large user base, making users access their profile page in the WordPress site’s admin panel via the default login page is something you should avoid. Wondering why? It’s a well-known fact that the WordPress login page appears to be bland and boring. No doubt, the login page serves as the central entry point for millions of WordPress sites worldwide. But what if your users don’t really need to access the dashboard? Well, users belonging to a membership site are not usually interested in accessing the WordPress admin dashboard (except when they need to create a post or perform edit operations). Thus, making those users open up the admin panel through the login page is likely going to prove bad for user experience. However, you can ensure to deliver an enhanced user experience (UX) by letting ...

WordPress – How to Display Breadcrumb without Plugin

Breadcrumbs are navigation links, used to display all the pages links leading from the homepage. Basically, it is placed at the top of the page and helps to backward navigation. In WordPress, breadcrumbs played an important role on the post page. Many WordPress plugins are available to adding breadcrumbs on your site. But we recommend you to use our simple code for display breadcrumb on your WordPress site. You can easily display breadcrumb on WordPress site without any plugin. In this tutorial, we’ll show you how to create and display breadcrumb in WordPress. Create Breadcrumbs: We’ve created a custom function called get_breadcrumb() to generate the breadcrumb links. You only need to add the get_breadcrumb() function code in functions.php file of the current theme. /**  * Generate breadcrumbs  * @author CodexWorld  * @authorURL www.codexworld.com  */ function get_breadcrumb() {     echo '...

WordPress – How to Display Most Popular Posts by Views

Displays the most viewed posts at the sidebar are very helpful for visitors to find out the most popular post of your site. This tutorial will show you the simple way to display the most popular posts by views without using any plugin. You can get the most popular posts using simple WordPress most viewed posts query. We’ll use the post Meta for storing the post views count. Using the stored Meta value, we’ll fetch the posts according to the views count. You need to modify only two files functions.php and single.php . After that, you can display the most popular posts using simple posts query. functions.php File Open the functions.php file of the activated theme and add the following code. setPostViews() function add or update the post meta with post_views_count meta key. /*  * Set post views count using post meta  */ function setPostViews($postID) {     $countKey = 'post_views_count';  ...

Add featured image or thumbnail to WordPress post

Featured image or post thumbnail is pretty useful for your WordPress site. Using this feature, you’ll be able to add the thumbnail to WordPress post. This article will explain about how to add featured image or post thumbnail in WordPress. All modern WordPress themes have already been embedded post thumbnail support. If you are a WordPress theme developer or want to build a custom theme, this tutorial will help you a lot for adding featured image support to your theme. Enable Featured Image and Set Thumbnail Size add_theme_support() function is used for enabling the featured image in WordPress. Using set_post_thumbnail_size() function, you can add the default featured image dimensions. Open the wp-content/themes/themeName/functions.php file and add the following code. /*  * Enable support for Post Thumbnails on posts and pages.  */ add_theme_support( 'post-thumbnails' ); //Set thumbnail dimensions se...

Speed up WordPress site instantly

In WordPress, lots of plugins are available and you can easily build a full-featured website with these plugins. These plugins and site’s theme include many JavaScript and CSS codes and it does affect your site speed. If your website takes the long time to load, most of the visitors can leave. According to the Google ranking algorithm, search ranking depends on site speed. So, the speed of your site influences the visitors and SEO. This WordPress optimization tutorial helps to speed up WordPress site and make WordPress faster instantly. Using two WordPress plugin, you can reduce site load time and improve speed. Follow our step by step guide mentioned below and load your site much faster. Before starting the optimization you can test website page speed. Some popular website speed testing sites are given below. Google Pagespeed Insights GTmetrix Pingdom Step 1: Install and configure W3 Total Cache Plugin W3 Total Cache is a popular WordPress plugin for easy Web Performance Optimization ...