Wednesday, 22 February 2017

Password and Confirm Password validation through jQuery

Password and Confirm Password validation through jQuery.

In this article I will explain you how to match Password and Confirm Password by using jQuery 
in Html.The values of the Password and Confirm Password are compared by using jQuery.
 An OnClick event handler button has been assigned when the button is click the values of textboxes 
are compared with each other if values does not match an alert message box will display that there is
an error password not match.

<table border="2" cellpadding="5" cellspacing="2">

    <tr>
        <td>Password:</td>
        <td><input type="password" id="pass" /></td>
    </tr>

    <tr>
          <td>Confirm Password:</td>
          <td><input type="password" id="conpass" /></td>
    </tr>

    <tr>
           <td> </td>
           <td><input type="button" id="btnSubmit" value="Submit" /></td>
    </tr>

</table>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<script type="text/javascript">
    $(function () {
        $("#btnSubmit").click(function () {
            var pass = $("#pass").val();
            var conpass = $("#conpass").val();
            if (pass != conpass) {
                alert("Passwords do not match.");
                return false;
            }
            return true;
        });
    });
</script>

How to match Password and Confirm Password.

Match Password and Confirm Password validation through JavaScript.

In this article I will explain you how to match Password and Confirm Password by using JavaScript.
The values of the Password and Confirm Password are compared by using JavaScript.
If both values does not match an error message will displayed on the screen.First of all If you want
to try this code you can simply run in text file through html it really works.


<table border="2" cellpadding="5" cellspacing="2">
    <tr>
           <td> Password:  </td>
           <td><input type="password" id="pass" /></td>
    </tr>

    <tr>
            <td>Confirm Password:</td>
            <td><input type="password" id="conpass" /></td>
    </tr>

   <tr>
       <td></td>
       <td><input type="button" id="btnSubmit" value="Submit" onclick="return Validate()" /></td>
   </tr>

</table>


<script type="text/javascript">
    function Validate() {
        var pass = document.getElementById("pass").value;
        var conpass = document.getElementById("conpass").value;
        if (pass!= conpass {
            alert("Passwords do not match.");
            return false;
        }
        return true;
    }
</script>

Tuesday, 21 February 2017

How to Show Roman Number System.

                                                 Roman Number System 

Symbol    Symbol Name                                      Dec                  Hex
Ⅰ              Roman Number for One                     &#8544;          &#x2160;
Ⅱ             Roman Number for Two                     &#8545;          &#x2161;
Ⅲ            Roman Number for Three                   &#8546;          &#x2162;
Ⅳ           Roman Number for Four                     &#8547;          &#x2163;
Ⅴ            Roman Number for Five                      &#8548;          &#x2164;
Ⅵ           Roman Number for Six                        &#8549;          &#x2165;
Ⅶ          Roman Number for Seven                    &#8550;          &#x2166;
Ⅷ         Roman Number for Eight                      &#8551;           &#x2167;
Ⅸ          Roman Number for Nine                      &#8552;           &#x2168;
Ⅹ           Roman Number for Ten                        &#8553;           &#x2169;
Ⅺ          Roman Number for Eleven                   &#8554;           &#x216A;
Ⅻ          Roman Number for Twelve                  &#8555;           &#x216B;
Ⅼ            Roman Number for Fifty                      &#8556;           &#x216C;
Ⅽ           Roman Number One Hundred             &#8557;            &#x216D;
Ⅾ           Roman Number for Five Hundred        &#8558;           &#x216E;Ⅿ           Roman Number for One Thousand      &#8559;           &#x216F;

Currency Sign on Html pages.

                                        Currency Sign

To Show Dollar Sign on Html pages .

  • $  ---  For Dollar Sign     ---          &#36;
  • ﹩   ---  a small dollar sign  ---          &#65129;
  •  ---  Bold Dollar Sign   ---          &#128178;
  •  ---  A Dollar Note      ---          &#128181;


To Show Cent Sign on Html pages .

  • ¢    --- for small cent sign         ---            &#162;
  • ¢ --- for big cent sign            ---            &#65504;

To Show Euro Sign on Html pages .

  • €   ---   For Euro Sign            ----      &#8364;  
  •   ---   For Euro Bank Note  ----      &#128182; 

To Show Florin Sign(Italy) on Html pages .
  
  • ƒ    ---  Florin sign  ---  &#402;     

To Show French Franc Sign on Html pages .

  • ₣   ---   French Franc ---   &#8355;

To Show Pesto(Spain) Sign on Html pages .


  •  ₧  --- Pesto ---             &#8359;


To Show Peso(Philippines) Sign on Html pages .

  • ₱  ---Peso----                 &#8369;

To Show Pound Sign on Html pages .

  • £   ---   Pound Sign by Unicode          ---         &#163;
  • £ ---   A simple Pound Sign              ---         &#65505; 
  • £   ---   A simple html code for pound ---         &pound; 


To Show Indian Rupees Sign on Html pages .

  • ₨      ---For old Standard of Indian Rupees  -----  &#8360;
  • ₹       ---New Style for Indian Rupees           -----  &#8377;

To Show Russian rouble Sign on Html pages .

  • ₽   ---  Russian Rouble  ----- &#8381;

To Show Turkish Lira Sign on Html pages .


  • ₺  ---Turkish Lira           ---- &#8378;

To Show Yen(Japan) Sign on Html pages .

  • ¥     --- A small Yen Sign --- &#165;
  • ¥   --- A big Yen Sign    --- &#65509;

To Show Yuan(China) Sign on Html pages .


  • 元 ------ First Method        ---------  &#x5143;
  • 元 ------ Second Method   ---------  &#20803;

To Show Won(South Korea) Sign on Html pages .

  • ₩    ---- First Method        ------     &#x20A9;
  • ₩    ---- Second Method   ------    &#8361;

To Show New Shekel(Israel) Sign on Html pages .

  • ₪  ---- First Method             ------&#x20AA;
  • ₪  ---- Second Method        ------&#8362;

To Show Dong(Vietnam) Sign on Html pages .

  • ₫   ---- First Method                 ------&#x20AB;
  • ₫   ---- Second Method            ------&#8363;





What is Linux netstat command & How we can use it.


The Netstat command is used to display various network-related information such as network connection, routing table, interface statistics, masquerade connections, multicast group members, and so on.

On the whole, netstat output can be divided into two parts:

One is Active Internet connections, called active TCP connections, where "Recv-Q" and "Send-Q" means% 0A is the receive queue and the send queue. These numbers should generally be 0. If not, the package is being stacked in the queue. This can only be seen in very rare cases.

The other is Active UNIX domain sockets, called active Unix domain socket (and network socket, but can only be used for local communication, performance can be doubled).
ProtC shows the protocol used by the connection, RefCnt represents the process number connected to this interface, Types shows the type of socket, State displays the current state of the socket, and Path represents the pathname used by other processes connected to the socket.

Common parameters
-a (all) Displays all options, and LISTEN is not displayed by default
-t (tcp) Show only tcp related options
-u (udp) Show only udp related options
-n refuses to display aliases, can show all the numbers into numbers.
-l only lists the status of the service in Listen (listen)

-p Displays the name of the program that created the associated link
-r Displays the routing information and routing table
-e Displays extended information such as uid
-s Statistics by protocol
-c Execute the netstat command every other fixed time.

Tip: LISTEN and LISTENING state only with-a or-l can see

A practical command instance

1. List all ports (including listening and unregistered)
List all ports netstat -a
List all tcp ports netstat -at
List all udp ports netstat -au

2. List all Sockets that are listening
Only show the listening port netstat -l
Only list all tcp port netstat -lt

3. Display the statistics for each protocol
Display statistics for all ports netstat -s

4. Display the PID and the process name netstat -p in the netstat output
Netstat -p can be used with other switches, you can add "PID / process name" to the netstat output, so debugging time can be very convenient to find a specific port to run the program.

5. In the netstat output does not show the host, port and user name (host, port or user)
When you do not want the host, port and username display, use netstat -n. Will use numbers instead of those names.
The same can speed up the output, because no comparison query.

6. Continue to output netstat information
Netstat will output network information every second.

7. Show the system does not support the address family (Address Families)

Netstat -verbose
At the end of the output, the following information is available

8. Display the core routing information netstat -r
Note: Use netstat -rn to display the number format without querying the host name.

9. Locate the port on which the program is running
Not all processes can be found, there is no permission will not show, use the root privileges to view all the information.

10. Display the network interface list

11. IP and TCP analysis
View the maximum number of IP addresses that connect to a service port

Monday, 20 February 2017

ALT Codes List with Symbol.


ALT Codes List with Symbol by simply press alt key with numerical keys.

Alt + 1
Alt + 2
Alt + 3
Alt + 4
Alt + 5
Alt + 6
Alt + 7
Alt + 8
Alt + 9
Alt + 10
Alt + 11
Alt + 12
Alt + 13
Alt + 14
Alt + 15
Alt + 16
Alt + 17
Alt + 18  ↕
Alt + 19  ‼
Alt + 20  ¶
Alt + 21  §
Alt + 22
Alt + 23  ↨
Alt + 24  ↑
Alt + 25  ↓
Alt + 26
Alt + 27
Alt + 28
Alt + 29
Alt + 30
Alt + 31
Alt + 32 Space
Alt + 33  !
Alt + 34  "
Alt + 35  #
Alt + 36  $
Alt + 37  %
Alt + 38  &
Alt + 39   '
Alt + 40   (
Alt + 41   )
Alt + 42   *
Alt + 43   +
Alt + 44     ,
Alt + 45   -
Alt + 46   .
Alt + 47   /
Alt + 48   0
Alt + 49   1
Alt + 50   2
Alt + 51     3
Alt + 52   4
Alt + 53      5
Alt + 54    6
Alt + 55      7
Alt + 56      8
Alt + 57      9
Alt + 58       :
Alt + 59       ;
Alt + 60      <
Alt + 61      =
Alt + 62      >
Alt + 63      ?
Alt + 64  @
Alt + 65      A
Alt + 66  B
Alt + 67  C
Alt + 68  D
Alt + 69  E
Alt + 70  F
Alt + 71 G
Alt + 72 H
Alt + 73 I
Alt + 74 J
Alt + 75 K
Alt + 76 L
Alt + 77 M
Alt + 78 N
Alt + 79 O
Alt + 80 P
Alt + 81 Q
Alt + 82 R
Alt + 83 S
Alt + 84 T
Alt + 85 U
Alt + 86 V
Alt + 87 W
Alt + 88 X
Alt + 89 Y
Alt + 90 Z
Alt + 91 [
Alt + 92 \
Alt + 93 ]
Alt + 94 ^
Alt + 95 _
Alt + 96   `
Alt + 97 a
Alt + 98 b
Alt + 99 c
Alt + 100 d
Alt + 101 e
Alt + 102 f
Alt + 103 g
Alt + 104 h
Alt + 105 i
Alt + 106 j
Alt + 107 k
Alt + 108 l
Alt + 109 m
Alt + 110 n
Alt + 111 o
Alt + 112 p
Alt + 113 q
Alt + 114  r
Alt + 115  s
Alt + 116  t
Alt + 117  u
Alt + 118  v
Alt + 119  w
Alt + 120   x
Alt + 121   y
Alt + 122   z
Alt + 123  {
Alt + 124   |
Alt + 125  }
Alt + 126  ~
Alt + 127  ⌂
Alt + 128  Ç
Alt + 129  ü
Alt + 130  é
Alt + 131  â
Alt + 132  ä
Alt + 133  à
Alt + 134  å
Alt + 135  ç
Alt + 136  ê
Alt + 137  ë
Alt + 138  è
Alt + 139  ï
Alt + 140  î
Alt + 141  ì
Alt + 142  Ä
Alt + 143 Å
Alt + 144 É
Alt + 145 æ
Alt + 146 Æ
Alt + 147   ô
Alt + 148  ö
Alt + 149  ò
Alt + 150  û
Alt + 151  ù
Alt + 152  ÿ
Alt + 153  Ö
Alt + 154  Ü
Alt + 155  ¢
Alt + 156  £
Alt + 157  ¥
Alt + 158
Alt + 159  ƒ
Alt + 160  á
Alt + 161   í
Alt + 162  ó
Alt + 163  ú
Alt + 164    ñ
Alt + 165 Ñ
Alt + 166  ª
Alt + 167  º
Alt + 168  ¿
Alt + 169  ⌐
Alt + 170  ¬
Alt + 171  ½
Alt + 172  ¼
Alt + 173   ¡
Alt + 174    «
Alt + 175   »
Alt + 176   ░
Alt + 177   ▒
Alt + 178   ▓
Alt + 179  │
Alt + 180  ┤
Alt + 181  ╡
Alt + 182  ╢
Alt + 183  ╖
Alt + 184   ╕
Alt + 185  ╣
Alt + 186  ║
Alt + 187  ╗
Alt + 188  ╝
Alt + 189  ╜
Alt + 190  ╛
Alt + 191  ↕
Alt + 192   └
Alt + 193  ┴
Alt + 194  ┬
Alt + 195  ├
Alt + 196  ─
Alt + 197  ┼
Alt + 198  ╞
Alt + 199  ╟
Alt + 200  ╚
Alt + 201  ╔
Alt + 202  ╩
Alt + 203  ╦
Alt + 204  ╠
Alt + 205  ═
Alt + 206  ╬
Alt + 207  ╧
Alt + 208  ╨
Alt + 209  ╤
Alt + 210  ╥
Alt + 211  ╙
Alt + 212  ╘
Alt + 213  ╒
Alt + 214  ╓
Alt + 215  ╫
Alt + 216  ╪
Alt + 217  ┘
Alt + 218
Alt + 219  █
Alt + 220  ▄
Alt + 221  ▌
Alt + 222   ▐
Alt + 223
Alt + 224 α
Alt + 225 ß
Alt + 226 Γ
Alt + 227 π
Alt + 228 Σ
Alt + 229 σ
Alt + 230 µ
Alt + 231 τ
Alt + 232 Φ
Alt + 233 Θ
Alt + 234 Ω
Alt + 235 δ
Alt + 236
Alt + 237 φ
Alt + 238 ε
Alt + 239
Alt + 240
Alt + 241 ±
Alt + 242
Alt + 243   ≤
Alt + 244
Alt + 245
Alt + 246 ÷
Alt + 247
Alt + 248 °
Alt + 249  ∙
Alt + 250  ·
Alt + 251  √
Alt + 252   ⁿ
Alt + 253   ²
Alt + 254   ■



What is the Defination of Apache Solr ?


It is an open source search platform which is  built upon a Java library called Lucene.

Solr is a popular search platform for enterprise search because it can be used to index and search documents and email attachments also. It is a popular search platform for Web sites because it can index and search multiple sites and return recommendations for related content based on the search query’s taxonomy.

Solr also works with Hypertext Transfer Protocol (HTTP) & Extensible Markup Language (XML). It offers various application program interfaces (APIs) for Javascript Object Notation (JSON), Python, and Ruby. According to the Apache Lucene Project, Solr offers capabilities that have made it popular with administrators including:

  1.     Load-balanced querying
  2.     Geo-spatial searching
  3.     Automated fail over and recovery
  4.     Indexing in near real time
  5.     Rich document parsing and indexing    
  6.     Automated index replication
  7.     Server statistics logging
  8.     Design for high-volume traffic
  9.     Multiple search indexes
  10.     User-extensible caching
  11.     Scalability, flexibility and extensibility
  12.     Advanced full-text searching
   
   

How to add animations on button through Css.


Animated Effects on Button



<style>
.button {
  padding: 16px 26px;
  font-size: 25px;
  text-align: center;
  cursor: pointer;
  outline: none;
  color: #fff;
  background-color: #744AFF;
  border: none;
  border-radius: 16px;
  box-shadow: 0 10px #999;
}

.button:hover {background-color: #3e8e41}

.button:active {
  background-color: #00a2ff;
  box-shadow: 0 6px #000;
  transform: translateY(4px);
}
</style>

Friday, 17 February 2017

HTML Color with their names

HTML COLOR NAMES

Gold #FFD700
Yellow #FFFF00
LightYellow#FFFFE0
LemonChiffon #FFFACD
LightGoldenrodYellow#FAFAD2
PapayaWhip#FFEFD5
Moccasin #FFE4B5
PeachPuff#FFDAB9
PaleGoldenrod #EEE8AA
Khaki #F0E68C
DarkKhaki#BDB76B
Lavender #E6E6FA
Thistle #D8BFD8
Plum #DDA0DD
Violet #EE82EE
Orchid #DA70D6
Fuchsia #FF00FF
Magenta #FF00FF
MediumOrchid #BA55D3
MediumPurple #9370DB
Amethyst #9966CC
BlueViolet#8A2BE2
DarkViolet#9400D3
DarkOrchid#9932CC
DarkMagenta#8B008B
Purple #800080
Indigo #4B0082
SlateBlue#6A5ACD
DarkSlateBlue #483D8B
MediumSlateBlue#7B68EE
GreenYellow#ADFF2F
Chartreuse#7FFF00
LawnGreen#7CFC00
Lime #00FF00
LimeGreen#32CD32
PaleGreen#98FB98
LightGreen#90EE90
MediumSpringGreen#00FA9A
SpringGreen#00FF7F
MediumSeaGreen #3CB371
SeaGreen #2E8B57
ForestGreen#228B22
Green #008000
DarkGreen#006400
YellowGreen#9ACD32
OliveDrab#6B8E23
Olive #808000
DarkOliveGreen #556B2F
MediumAquamarine#66CDAA
DarkSeaGreen #8FBC8F
LightSeaGreen #20B2AA
DarkCyan #008B8B
Teal #008080
Aqua #00FFFF
Cyan #00FFFF
LightCyan#E0FFFF
PaleTurquoise #AFEEEE
Aquamarine#7FFFD4
Turquoise#40E0D0
MediumTurquoise#48D1CC
DarkTurquoise #00CED1
CadetBlue#5F9EA0
SteelBlue#4682B4
LightSteelBlue #B0C4DE
PowderBlue#B0E0E6
LightBlue#ADD8E6
SkyBlue #87CEEB
LightSkyBlue #87CEFA
DeepSkyBlue#00BFFF
DodgerBlue#1E90FF
CornflowerBlue #6495ED
MediumSlateBlue#7B68EE
RoyalBlue#4169E1
Blue #0000FF
MediumBlue#0000CD
DarkBlue #00008B
Navy #000080
MidnightBlue #191970
White #FFFFFF
Snow #FFFAFA
Honeydew #F0FFF0
MintCream#F5FFFA
Azure #F0FFFF
AliceBlue#F0F8FF
GhostWhite#F8F8FF
WhiteSmoke#F5F5F5
Seashell #FFF5EE
Beige #F5F5DC
OldLace #FDF5E6
FloralWhite#FFFAF0
Ivory #FFFFF0
AntiqueWhite #FAEBD7
Linen #FAF0E6
LavenderBlush #FFF0F5
MistyRose#FFE4E1
Gainsboro#DCDCDC
LightGrey#D3D3D3
Silver #C0C0C0
DarkGray #A9A9A9
Gray #808080
DimGray #696969
LightSlateGray #778899
SlateGray#708090
DarkSlateGray #2F4F4F
Black #000000
IndianRed#CD5C5C
LightCoral#F08080
Salmon #FA8072
DarkSalmon#E9967A
LightSalmon#FFA07A
Crimson #DC143C
Red #FF0000
FireBrick#B22222
DarkRed #8B0000
Pink #FFC0CB
LightPink#FFB6C1
HotPink #FF69B4
DeepPink #FF1493
MediumVioletRed#C71585
PaleVioletRed #DB7093
LightSalmon #FFA07A
Coral #FF7F50
Tomato #FF6347
OrangeRed#FF4500
DarkOrange#FF8C00
Orange #FFA500
Cornsilk #FFF8DC
BlanchedAlmond #FFEBCD
Bisque #FFE4C4
NavajoWhite#FFDEAD
Wheat #F5DEB3
BurlyWood#DEB887
Tan #D2B48C
RosyBrown#BC8F8F
SandyBrown#F4A460
Goldenrod#DAA520
DarkGoldenrod #B8860B
Peru #CD853F
Chocolate#D2691E
SaddleBrown#8B4513
Sienna #A0522D
Brown #A52A2A
Maroon #800000

Get Distance Through Zipcode.


Make this Function into your Model in Codeigniter.

function zipcode($addr){
    if(!empty($addr)){
        //Address format
        $formattedaddress = str_replace(' ','+',$addr);

        //Send request and receive data by address through Json
        $mapcodeFromaddr = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.$formattedaddr.'&sensor=true_or_false');
        $outcome1 = json_decode($mapcodeFromaddr);
        //Get latitude and longitute data through Json
        $lat  = $outcome1->results[0]->geometry->location->lat;
        $long = $outcome1->results[0]->geometry->location->long;

        //Send request and receive json data by latitude longitute
        $mapcodeFromlatlong = getfile_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng='.$latitude.','.$long.'&sensor=true_or_false');
        $outcome2 = json_decode($mapcodeFromlatlong);
        if(!empty($outcome2)){
            $addrcomponents = $outcome2->results[0]->addr_components;
            foreach($addrcomponents as $addrcomp){
                if($addrcomp->types[0] == 'postal_code'){
                    //Return the zipcode
                    return $addrcomp->long_name;
                }
            }
            return false;
        }else{
            return false;
        }
    }
    else{
        return false;
    }
}


If you want to use this Google API Key in your code it will helps you how?. If your daily request limit exceed then you would not get any result this Api Key will helps you .

$mapcodeFromaddr = getfile_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.$formattedaddr.'&sensor=true_or_false&key=GoogleAPIKey');


Calculate Distance Through Google Maps

Make this Function into your Model in CodeIgniter.

function getdist($addrFrom, $addrTo, $measurement){

    $formattedaddressFrom = str_replace(' ','+',$addrFrom);
    $formattedaddressTo = str_replace(' ','+',$addrTo);
   
    //Send request and receive data through json
      $mapcodeFrom = getfile_contents('http://maps.google.com/maps/api/geocode/json?address='.$formattedaddressFrom.'&sensor=false');
    $outcomeFrom = json_decode($mapcodeFrom);
    $mapcodeTo = getfile_contents('http://maps.google.com/maps/api/geocode/json?address='.$formattedaddressTo.'&sensor=false');
    $outcomeTo = json_decode($mapcodeTo);
   
    //Get the latitude and longitude from geo data
    $latFrom = $outcomeFrom->results[0]->geometry->location->lat;
    $longFrom = $outcomeFrom->results[0]->geometry->location->long;
    $latTo = $outcomeTo->results[0]->geometry->location->lat;
    $longTo = $outcomeTo->results[0]->geometry->location->long;
   
    //Calculate the distance from latitude and longitude
    $theta = $longitudeFrom - $longitudeTo;
    $dist = sin(deg2rad($latFrom)) * sin(deg2rad($latTo)) +  cos(deg2rad($latFrom)) * cos(deg2rad($latTo)) * cos(deg2rad($theta));
    $dist = acos($dist);
    $dist = rad2deg($dist);
    $miles = $dist * 60 * 1.1515;
    $measurement = strtoupper($measurement);
    if ($measurement == "KM") {
        return ($miles * 1.609344).' km';
    } else if ($measurement == "NM") {
        return ($miles * 0.8684).' nm';
    } else {
        return $miles.' mi';
    }
}

  //If you want to use this Google API Key in your code it will helps you how?. If your daily request limit exceed then you would not get any result this Api Key will helps you .

$mapcode = getfile_contents('https://maps.google.com/maps/api/geocode/json?address='.$formattedaddr.'&sensor=false&key=GoogleAPIKey');


Pagination With Jquery

How to do pagination on your webpage through Jquery use this script on to your web page & use the library of jquery.min.js and version 3.1.1.

$(function(){
        pag_size = 10;
           var page_num =  $("div.wsContent").length / pag_size;
               for(var j = 0 ; j<page_num;j++){
                $(".pagein").append('<a href="javascript:void(0)">'+(j+1)+'</a>');
                }
                $(".pagein a:first").addClass("active");
              show_page = function(page) {
                 $("div.wsContent").fadeOut(100);
                  $("div.wsContent").each(function(n) {
                      if (k >= pag_size * (page - 1) && k < pag_size * page)
                       $(this).fadeIn(200);
                    });      
                   }

                show_page(1);

                  $(".pagein a").click(function() {
                     $(".pagein a").removeClass("active");
                     $(this).addClass("active");
                     show_page(parseInt($(this).text()))
             });
           });

Wednesday, 15 February 2017

Calculate day hours and minutes between Registration Date and current Datetime.

Make this function into your Model.

function dateDiff($date)
    {
      $mydate= date("Y-m-d H:i:s");
      $theDiff="";
      //echo $mydate;//2014-06-06 21:35:55
      $datetime1 = date_create($date);
      $datetime2 = date_create($mydate);
      $interval = date_diff($datetime1, $datetime2);
      //echo $interval->format('%s Seconds %i Minutes %h Hours %d days %m Months %y Year    Ago')."<br>";
      $min=$interval->format('%i');
      $sec=$interval->format('%s');
      $hour=$interval->format('%h');
      $mon=$interval->format('%m');
      $day=$interval->format('%d');
      $year=$interval->format('%y');
      if($interval->format('%i%h%d%m%y')=="00000")
      {
        //echo $interval->format('%i%h%d%m%y')."<br>";
        return $sec." Seconds";

      }

    else if($interval->format('%h%d%m%y')=="0000"){
       return $min." Minutes";
       }

    else if($interval->format('%d%m%y')=="000"){
       return $hour." Hours";
       }

    else if($interval->format('%m%y')=="00"){
       return $day." Days";
       }

    else if($interval->format('%y')=="0"){
       return $mon." Months";
       }

    else{
       return $year." Years";
       }

    }



Now call this model into your function in controller like this..

public function home()
    {
        $this->load->model('mode');
        $data['main_content'] = 'home';
        $this->load->view('templates',$data);
   }


Now write this code into your view

<?php echo date('Y-m-d', strtotime($row->edate)) ;?>&nbsp;&nbsp;&nbsp;<i class='fa fa-clock-o'></i>&nbsp;<?php echo $this->mode->dateDiff($row->edate) ;?>

// edate comes from database.



Tuesday, 14 February 2017

Send Password Through Mail by accessing database.

Make this Function into your Controller and call this function on to your Viewpage.

function send_password()
     {
        $this->db->where('email',$this->input->post('email'));
        $query1 = $this->db->get('tablename from database');
        if($query1 ->num_rows() > 0)
        {
            foreach ($query1->result() as $rows)
            {
                $name = $rows->firstname;
                $password = $rows->password;
                $subject= $name.",  Your Password was successfully delivered on your email";
                $message="";
                $message ='<p >Hi&nbsp;'.$name.',<br/><br/>
 You have Successfully Retrieve your password. <br/>
                 Your Password is : '.$password.' </p> ';

                $to=$rows->email;
                $headers  = "From: ".$_SERVER['HTTP_HOST']."\r\n";
                $headers .= "Content-type: text/html\r\n";
                if(mail($to,$subject,$message,$headers))
                {
                 echo "<script>
                  alert('Please Check Ur Mail Account... Your Password was Successfully delievered on your mail..');
                  window.location='".base_url()."index.php/controller/';      
                </script>";
                 }
            }
        }
        else{          
            echo "<script>
                  alert('Your Email is not in our database..');
                  window.location='".base_url()."index.php/controller/';
                 </script>"; }
    }

Send Mail By Using Smtp Authentication & Ssl Encryption in Php.

<?php
 require_once "Sendmail.php";

 $from = "<sender@abc.com>";
 $to = "<recipient@abc.com>";
 $subject = "Hi!";
 $body = "Hello";

 $host = "ssl://mail.abc.com";
 $port = "465";
 $uname = "smtp_uname";
 $pass = "smtp_pass";

 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' => $port,
     'author' => true,
     'uname' => $uname,
     'pass' => $pass));

 $mail = $smtp->send($to, $headers, $body);

 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Your Mail is successfully sent!</p>");
  }
 ?>

Send Mail By Using SMTP Authentication in Php.

<?php
 require_once "Sendmail.php";

 $from = "Sender <sender@abc.com>";
 $to = "Recipient <recipient@abc.com>";
 $subject = "Hi!";
 $body = "Hello";

 $host = "mail.abc.com";
 $uname = "smtp_uname";
 $pass = "smtp_pass";

 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'author' => true,
     'uname' => $uname,
     'pass' => $pass));

 $mail = $smtp->send($to, $headers, $body);

 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Your Mail Successfully Sent!</p>");
  }
 ?>

A Simple Send Mail Function in CodeIgniter

Make this function in your Model.

function send_mail($to,$firstname,$Mobile,$Country)
    {
            $subject = 'Save 3 Lives';
            $headers = "From: " . $_SERVER['HTTP_HOST'] . "\r\n";
            $headers .= "Reply-To: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n";
            $headers .= "CC: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
           
            $message = '<html><body>';
            $message .= '<h2 style="align:center">Thank You </h2>';'<br>';
            $message .= '<h2 style="align:center">Thank You </h2>';'<br>';
            $message .= '<table align="left" style="border-color: #000; margin: 16 pxauto; " cellpadding= " 10 ">';
            $message .= "<tr style='background: #437C17; color:#fff;'><td><strong>Dear:</strong> </td><td>" . $firstname . "</td></tr>";
            $message .= "<tr><td><strong>Email:</strong> </td><td>" . $to . "</td></tr>";
            $message .= "<tr><td><strong>Phone:</strong> </td><td>" . $Mobile . "</td></tr>";
            $message .= "<tr><td><strong>Country:</strong> </td><td>" . $Country . "</td></tr>";
            $message .= "</table>";
            $message .= "</body></html>";

         if(mail($to, $subject, $message, $headers))
            {
                return TRUE;
            }
        }


 Now put this code into your insert function at the end in Model to fetch data which you want to send.
 
       {  
             $this->send_mail($Email, $firstname, $Mobile, $Country);
        }





Calculate Distance by Latitude and Longitude in Java.

/* Remember South latitudes are negative, east longitudes are positive    */
/* Passed to function:                                                    */
/* lati1, long1 = Latitude and Longitude of point 1 (in decimal degrees)  */
/* lati2, long2 = Latitude and Longitude of point 2 (in decimal degrees)  */
/*          unit = the unit you desire for results                        */
/*           where: 'M' is statute miles (default)                        */
/*                  'K' is kilometers                                     */
/*                  'N' is nautical miles                                 */
------------------------------------------------------------------------
import java.util.*;
import java.lang.*;
import java.io.*;

class DistanceCalculator
{
 public static void main (String[] args) throws java.lang.Exception
 {
  System.out.println(distance(38.9697, -98.80322, 31.46786, -98.53506, "M") + " Miles\n");
  System.out.println(distance(38.9697, -98.80322, 31.46786, -98.53506, "K") + " Kilometers\n");
  System.out.println(distance(38.9697, -98.80322, 31.46786, -98.53506, "N") + " Nautical Miles\n");
 }

 private static double distance(double lati1, double long1, double lati2, double long2, String unit) {
  double theta = long1 - long2;
  double dist = Math.sin(deg2rad(lati1)) * Math.sin(deg2rad(lati2)) + Math.cos(deg2rad(lati1)) * Math.cos(deg2rad(lati2)) * Math.cos(deg2rad(theta));
  distance = Math.acos(distance);
  distance = rad2deg(distance);
  distance = distance * 60 * 1.1515;
  if (unit == "K") {
   distance = distance * 1.609344;
  } else if (unit == "N") {
   distance = distance * 0.8684;
  }

  return (distance);
 }

 /*--------------------------------------------------------------------*/
 /* This function is used to converts decimal degrees into radians*/
 /*--------------------------------------------------------------------*/
 private static double deg2rad(double deg) {
  return (deg * Math.PI / 180.0);
 }

 /*--------------------------------------------------------------------*/
 /* This function is used to converts radians into decimal degrees*/
 /*--------------------------------------------------------------------*/
 private static double rad2deg(double rad) {
  return (rad * 180 / Math.PI);
 }
}

Calculate Distance Between given by Latitude and Longitude in Php

<?php
                                                          
<----- Remember South latitudes are negative, east longitudes are positive.   ----->    
                                                      
<-----lati1, long1 = Latitude and Longitude of point 1 (in decimal degrees)   ----->
<-----lati2, long2 = Latitude and Longitude of point 2 (in decimal degrees)   ----->
<-----          unit = the unit you desire for results                        ----->
<-----           where: 'M' is statute miles (default)                        
                        'K' is kilometers                                     
                        'N' is nautical miles                                 ----->         

function distance($lati1, $long1, $lati2, $long2, $unit) {

  $theta = $long1 - $long2;
  $distance = sin(deg2rad($lati1)) * sin(deg2rad($lati2)) +  cos(deg2rad($lati1)) * cos(deg2rad($lati2)) * cos(deg2rad($theta));
  $distance = acos($distance);
  $distance = rad2deg($distance);
  $miles = $distance * 60 * 1.1515;
  $unit = strtoupper($unit);

  if ($unit == "K") {
    return ($miles * 1.609344);
  } else if ($unit == "N") {
      return ($miles * 0.8684);
    } else {
        return $miles;
      }
}

echo distance(38.9697, -98.80322, 31.46786, -98.53506, "M") . " miles<br>";
echo distance(38.9697, -98.80322, 31.46786, -98.53506, "K") . " kilometers<br>";
echo distance(38.9697, -98.80322, 31.46786, -98.53506, "N") . " nautical miles<br>";

?>

Friday, 10 February 2017

Calculate Distance through Haversine formula.

What do we need Haversine's Formula?
Just  to calculate the distance between longitude & latitude coordinates of two given places.



$('some_element').click(function(){
    var loc1 = [lat, lon] // It Specify Longitude and latitude
    var loc2 = [lat, lon] // It Specify Longitude and latitude

    var lat1 = loc1[0], lon1 = loc1[1];
    var lat2 = loc2[0], lon2 = loc2[1];
    var earth = 6371 // Earth's Radius in Kilometre

    var dLat = (lat2-lat1) * Math.PI / 180;
    var dLon = (lon2-lon1) * Math.PI / 180;
    var nlat1 = (lat1) * Math.PI / 180;
    var nlat2 = (lat2) * Math.PI / 180;

    // Calculation
    var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(nlat1) * Math.cos(nlat2);
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    var d = earth * c;
    var distance = Math.round(d*Math.pow(10,2)) / Math.pow(10,2); //Round off to 2 decimal places
    alert(distance);
});