Sample php code for sending OTP

Most of the user oriented website are slowly changing from email and password based login to OTP based login.so for a developer it is necessary to know how to create on OTP based login, here am going to share you Sample PHP code for sending OTP.

First you have to Register with any of the SMS Service providers ,here am using mysmsmantra.Here we are achieving with the help of CURL in PHP,this is the URL API from mysmsmantra for sedning OTP http://bulksms.mysmsmantra.com/WebSMS/SMSAPI.jsp?username=YOUR_USERNAME&password=YOUR_PASSWORD&sendername=rahaul&mobileno=*******&message=your OTP
where YOUR_USERNAME and YOUR_PASSWORD are respectively user name and password from mysmsmantra.

$otp=rand(100000, 999999);
$msg="Dear Customer, One Time Password for activating your account is :".$otp;
$message=urlencode($msg); 
$messageUrl="http://bulksms.mysmsmantra.com/WebSMS/SMSAPI.jsp?username=YOUR_USERNAME&password=YOUR_PASSWORD&sendername=rahaul&mobileno=*******&message=".$message; 
//YOUR_USERNAME and YOUR_PASSWORD are respectively from mysmsmantra
$ch = curl_init($messageUrl); 
$fp = fopen("message.txt", "w+"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FILE, $fp); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_exec($ch); curl_close($ch); 

fclose($fp);

Usage of for loop in Jquery syntax with example

Here am going to explain the use of for loop in JQuery with an example

Add a page ajax_angular_view.php with response format

{"Company1":"IBM","Company2":"TCL","Company3":"GOOGLE"}

HTML Area

 <div><input id="update_company_name_comapny1" type="text" value="" /></div>
<div><input id="update_company_name_comapny2" type="text" value="" /></div>
<div><input id="update_company_name_comapny3" type="text" value="" /></div>
var company_id=1
$.ajax({
                url: "ajax_angular_view.php?action=view_company_info_by_id&company_id="+company_id,
                type: "post",
                success: function(data) {
					
                    var obj = JSON.parse(data);
		for(var k in obj) {
					$("#update_company_name_"+k).val(obj[k])
 
                     }
		console.log(obj);
                     
                }
            });

How to add Auto suggestion in Jquery by customer name for customer id

T o add Auto suggestion in jquery for customer name and customer id

 $('#customer_name').autocomplete({
    source : function (request, response) {
        $.getJSON("ajax_angular_view.php?action=view_customers", {
            term: request.term
        }, function(data) {                     
            var array = data.error ? [] : $.map(data.Clist, function(m) {
                return {
					
                    label: m.name,
                    value: m.value
                };
            });
            response(array);
        });
    },   select: function (event, ui) {
		  event.preventDefault();
        $("#customer_name").val(ui.item.label); // display the selected text
        $("#user_id").val(ui.item.value); // save selected id to hidden input
        return false;
          }
,    focus: function(event, ui) {
        event.preventDefault();
        $("#customer_name").val(ui.item.label);
    }
});

ajax_angular_view.php?action=view_customers Result should be

{“Clist”:[{“name”:”Hareram Sharma”,”value”:”1″},{“name”:”Jitender”,”value”:”2″},{“name”:”soni”,”value”:”3″}]}

How to install LAMP in AWS server

Amazon Web Services is a one of the most flexible hosting service providers,but most of them are facing difficult how to install  LAMP (Apache , MySQL and PHP ) in AWS with out using paid Cpanel service . Here am going to ellobrate by steps how to install LAMP in AWS server

1 Install Apache

# sudo yum install httpd

# sudo systemctl start httpd.service

#sudo systemctl enable httpd.service

Try https://IP ADDRESS in browsers

 2  Install Database

#sudo yum install mariadb-server mariadb

# sudo yum install mariadb-server mariadb

# sudo mysql_secure_installation

#sudo systemctl enable mariadb.service

3) Install phpMyAdmin

# sudo yum Install phpMyAdmin

Try  http://yourIPaddress/phpmyadmin