Tuesday, February 6, 2018

Encode and decode string with Base64 using PHP

base64_encode — Encodes data with MIME base64
string base64_encode ( $string )
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
Base64-encoded data takes about 33% more space than the original data.

$plainText = '';
$base64 = base64_encode($plainText);
$base64url = strtr($base64, '+/=', '-_,');
echo $base64url;

$plainText = "aHR0cDovL3d3dy5waHBqYXZhc2NyaXB0LmNvbS8,";
$base64url = strtr($plainText, '-_,', '+/=');
$base64 = base64_decode($base64url);
echo $base64;

Encrypt a string with own encryption key using PHP

Data encryption is the more essential in the current world to maintain data privacy and to secure its form. Here we are providing a simple encryption method. Before explaining about coding will talk about Data Encryption.

Data encryption translates data into another form, or code so that only people with access to a secret key (formally called a decryption key) or password can read it. Encrypted data is commonly referred to as ciphertext, while unencrypted data is called plaintext. Currently, encryption is one of the most popular and effective data security methods used by organizations. Two main types of data encryption exist - asymmetric encryption, also known as public-key encryption, and symmetric encryption.
//sting which you want to encrypt
$str = '';
//the secryt key which encrypts the sting

if ($ky == '') {
    echo $str;
} else {
    $ky = str_replace(chr(32), '', $ky);
    if (strlen($ky) < 8) {
        echo 'the key length should be more than 8';
    } else {
        $kl = strlen($ky) < 32 ? strlen($ky) : 32;
        $k = array();
        for ($i = 0; $i < $kl; $i++) {
            $k[$i] = ord($ky{$i}) & 0x1F;
        $j = 0;
        for ($i = 0; $i < strlen($str); $i++) {
            $e = ord($str{$i});
            $str{$i} = $e & 0xE0 ? chr($e ^ $k[$j]) : chr($e);
            $j = $j == $kl ? 0 : $j;
        echo $str;

Spinning Icons Using HTML, CSS and BOOTSTRAP

<link href="//" rel="stylesheet">
<style> {
list-style: none;
display: inline;
margin-left:0 !important;
padding: 0;
} li {
display: inline;
margin: 0 5px;
.social-network a.icoRss:hover {
background-color: #F56505;
.social-network a.icoFacebook:hover {
.social-network a.icoTwitter:hover {
.social-network a.icoGoogle:hover {
.social-network a.icoVimeo:hover {
.social-network a.icoLinkedin:hover {
.social-network a.icoRss:hover i, .social-network a.icoFacebook:hover i, .social-network a.icoTwitter:hover i,
.social-network a.icoGoogle:hover i, .social-network a.icoVimeo:hover i, .social-network a.icoLinkedin:hover i {
a.socialIcon:hover, .socialHoverClass {
.social-circle li a {
margin:0 auto 0 auto;
width: 50px;
height: 50px;
.social-circle li i {
text-align: center;
.social-circle li a:hover i, .triggeredHover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-ms--transform: rotate(360deg);
transform: rotate(360deg);
-webkit-transition: all 0.2s;  
-moz-transition: all 0.2s;
-o-transition: all 0.2s;
-ms-transition: all 0.2s;
transition: all 0.2s;
.social-circle i {
color: #fff;
-webkit-transition: all 0.8s;
-moz-transition: all 0.8s;
-o-transition: all 0.8s;
-ms-transition: all 0.8s;
transition: all 0.8s;
a {
background-color: #D3D3D3;
<div class="col-md-12">
<ul class="social-network social-circle" >
<li><a href="" class="icoRss" title="Rss"><i class="fa fa-rss"></i></a></li>
<li><a href="" class="icoFacebook" title="Facebook"><i class="fa fa-facebook"></i></a></li>
<li><a href="" class="icoTwitter" title="Twitter"><i class="fa fa-twitter"></i></a></li>
<li><a href="" class="icoGoogle" title="Google +"><i class="fa fa-google-plus"></i></a></li>
<li><a href="" class="icoLinkedin" title="Linkedin"><i class="fa fa-linkedin"></i></a></li>

Note:  Browser version that fully supports the property.
      -webkit-google chrome
      -moz-mozilla firefox


How to add google map to website using JavaScript API?

Google Map is the easiest way to display a map on the web page.
To display Google Map we need to get the latitude and longitude of our desired location. We need to specify our location’s latitude and longitude into the LatLng() method which is already shown in the example. At first, load the Google Maps JavaScript API and provide your API Key in key parameter.

<script src="">

Google Maps JavaScript API is free to create and you can get API key from Google API Console. This step-by-step tutorial will help you to generate an API key on Google Developer Console and get API key for Google Maps JavaScript API.

Step1: Log in to your Google account and go to the GoogleAPI Console. Step2: Click Project » Create project at the top left corner to creating a project. Step3: Enter the Project name and click on Create. It will take some seconds for creating a new project. Step4: Click the Library link on the left navigation menu. Under the Google Maps APIs section and click Google Maps JavaScript API link. Step5: Click ENABLE to use Google Maps JavaScript API. Step6: Click on Credentials on the left navigation menu. On the Credentials page,  click Create credentials » API key. Step7: A dialog box will appear with your newly created API Key. Use this API key with Google Maps JavaScript API. Below is the sample code will embed Google map in the website. <html> <head> <title>Adding Google Map on Your Website</title> <style> #map { width: 50%; height: 25%; } </style> <script src=" js?KEY=AIzaSyBbdB5D0kwt04dHbOR45ppzdcGrXqX9lIY"></script> <script> var myCenter = new google.maps.LatLng(17.4410, 78.4986); function initialize() { var mapProp = { center: myCenter, zoom: 12, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map"),mapProp); var marker = new google.maps.Marker({ position: myCenter, }); marker.setMap(map); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map"></div> </body> </html>


Simple User Registration Form Using PHP, MySQL