From personal blog, travel blog to company web page, we need to embed Google Map to show proper location. There are few WordPress plugins available to serve the same feature. But I always intend to not using WordPress plugins if it can be served by writing code.
We can create a simple WordPress shortcode to enable Google Map embed feature inside post or page.
Online payment is the hype of today’s web world. For getting any service or product we prefer to online payment method and PayPal is the most secure payment gateway. If you have a very basic knowledge of PHP, you can easily implement the simple PayPal gateway in your site.
The Process to implement PayPal on your website:
We can simplify the process into 3 steps – PayPal button, PDT and confirmation.
Recently I faced a tough situation with one of my WordPress site at the time of exporting MySQL database. My development MySQL server supports utf8mb4 collation but the production MySQL server does not support that. So, I had to convert all the tables of the MySQL database from utf8mb4 to utf8. The actual task was conversion from utf8mb4_unicode_ci to utf8_general_ci
I tried to convert manually several times but it did not work. My question was what is the difference between utf8mb4 and utf8?
utf8mb4 (as well as standard UTF-8) can directly store any character specified by Unicode; the former is fixed size at 4 bytes per character whereas the latter is between 1 and 4 bytes per character.
utf8 can only store the first 65,536 codepoints, which will cover CJVK (Chinese, Japanese, Vietnam, Korean), and use 1 to 3 bytes per character.
So, the real process will be ALTER the database as well as each database table to change the CHARACTER SET. Using a PHP script I made the conversion and it worked perfectly. This is the PHP script which will convert your MySQL database collation from utf8mb4_unicode_ci to utf8_general_ci instantly.
- Copy the above PHP script and paste in a file say, ‘dbconversion.php’.
- Now put this file in your server (development/production).
- Run this script from ‘yourdomain.com/dbconversion.php’.
- It’s all. It will convert everything and you will get a success message.
Note: If you are using WordPress website and you need to convert your database any time, make sure ‘utf8’ Charset will be defined in your ‘wp-config.php’ file as
We generally do not know the latitude and longitude of our area or any other area if we have needed to get the information. Sometimes we have to Google for getting this information. It is not a big issue to find out the approximate latitude and longitude for any location and it can easily be done in PHP.
Here I am writing the procedures to do the same.
- Create a PHP page say ‘postal_lang_long.php’ .
- Put the following codes in the PHP file.
- Now place your PHP file in your web server and open the file in any browser.
- Now in your browser you can see a text box asking for the name of the place.
- Enter the place-name and hit ‘go’ button.
- That’s all, you will be shown the latitude and longitude of your location.
You like to add photos in your Instagram. How it would be if you can show your Instagram images on your webpage? It would be really nice. If you have basic HTML knowledge, you can implement that by following the 2 process mentioned below:
Step 1: First you need to authenticate your Instagram account and obtain user id and access token key.
User id: http://www.pinceladasdaweb.com.br/instagram/user-id/
Go to this URL and put your Instagram username and it will give your Instagram user id.
Access token key: http://www.pinceladasdaweb.com.br/instagram/access-token/
Go to this URL and login with your Instagram account, authenticate your login and it will give your Instagram access token key.
Step 2: Now paste the following code in your web page where you want to display your Instagram image feed.
In the above code put your Instagram user id, access token where it mentions (xxxx). Also, you can change the image dimension of the feed, you just need to edit the image height and width tag value.
This topic is just for fun. I don’t know if there is any real implementation of this script or not. Suppose, we have lots of files and folders in a directory and we want to delete all the files and folders at a time. In such cases the following script will take the key role.
Step 1: Create PHP file, say remove.php .
Step 2: Put the following PHP codes inside remove.php file.
Step 3: Place this remove.php file inside the directory for which you want to delete the files and folders.
Step 4: Now open the file in your browser as : http://www.yourdomain.com/remove.php
You will get a message ‘All files have been removed’.
It will delete all the files and folders of your directory and the main notice is, the file remove.php will also be deleted.
Warning : Please do not use this script for any harmful or destructive cause.
There are so many times we don’t want to use any PHP file (say contact.php) directly for our HTML websites to process contact form rather we prefer to use HTML contact page (say contact.html). It is not a hard task, we can do this by using Ajax or jQuery. In this tutorial I am describing the easiest way to do the same.
The form will be in any HTML extension page with validation. What we need a separate PHP file for parsing email function only.
Here are the screen shots of the forms.
Step 1: Create an HTML page (contact.html) and write the form code with jQuery library CDN and validation script file adding.
Step 2: Add a JS file for the form validation and Ajax function of jQuery to get all the data from the submission of the form as soon as the form sends the values to email.php .
Step 3: Create a php file as email.php and write down the main PHP mail function.
Demo | Download