Thursday, February 6, 2020

How Can We Make Show/Hide Password Using AngularJS

How Can We Make Show/Hide Password Using AngularJS

In web development, we would like to hide input fields as a password at some point, since the user must check the password that he entered in the password fields at the time of user registration on the website or another type in which form the password field is required. If you used the AngularJS JavaScript framework for website development, you can add features such as changing the password on your website in this tutorial. This function allows the user to see the password he has completed in the password field. We created this password hiding feature using a simple AngularJS script.

If you are working in any form and on this form, you may have to use the password entry field. Here we used the Bootstrap CSS library with AngularJS, so we can use the glyph symbol with this library to create an elegant user interface. When we want to display the password, the open eye icon is displayed. If we want to hide the password, the closed eye password is displayed. Therefore, the user can better understand what he wants to show and hide the password.

To change the text of the show hide password, we used instructions other than the AngularJS JavaScript framework. By using the magic of the Rich Angular directive, we can achieve our goal of hiding the function of displaying the password in our form. Here we used a simple AngularJS expression with a name like inputType in the input field type attribute. When the page loads, we set this expression value to password so that the type of the input fields is password in The page is loading and we cannot see what characters have been entered in these fields. After that, we created an AngularJS function, and this function detects if the inputType expression value is a password, changes to text, and if the inputType expression value is text, it changes to password. With this simple method we can change the visibility of the password with AngularJS. Below is the complete source code and online display of the password for hiding with AngularJS.


index.php



<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>How Can We Make Show/Hide Password Using AngularJS</title>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
  <style>
  .form_style
  {
   width: 600px;
   margin: 0 auto;
  }
  </style>
 </head>
 <body>
  
  <div class="container" ng-app="show_hide_password" ng-controller="show_hide_password_controller">
   <br />
   <h2 align="center">Show Hide Password in Form with AngularJS</h2><br />

   <div class="panel panel-default form_style">
    <div class="panel-heading">
     <h3 class="panel-title">Login</h3>
    </div>
    <div class="panel-body">
     <div class="form-group">
      <label>Enter Email</label>
      <input type="text" name="email" class="form-control input-lg" ng-model="email_field" placeholder="Enter Email">
     </div>
     <div class="form-group">
      <label>Enter Password</label>
      <div class="input-group">
       <input type="{{inputType}}" name="password" class="form-control input-lg" ng-model="password_field" placeholder="Enter Password" />
       <span class="input-group-addon">
        <span class="{{showHideClass}}" ng-click="showPassword()" style="cursor:pointer"></span>
       </span>
      </div>
     </div>

    </div>
   </div>

  </div>
  
  <br />
  <br />
  <br />
 </body>
</html>


<script>
 
 var app = angular.module('show_hide_password', []);

 app.controller('show_hide_password_controller', function($scope){

  $scope.inputType = 'password';
  $scope.showHideClass = 'glyphicon glyphicon-eye-open';

  $scope.showPassword = function(){
   if($scope.password_field != null)
   {
    if($scope.inputType == 'password')
    {
     $scope.inputType = 'text';
     $scope.showHideClass = 'glyphicon glyphicon-eye-close';
    }
    else
    {
     $scope.inputType = 'password';
     $scope.showHideClass = 'glyphicon glyphicon-eye-open';
    }
   }
  };

 });

</script>


Create Autocomplete Textbox In AngularJS Tutorial

Create Autocomplete Textbox In AngularJS Tutorial

Hello friends in this post, let's discuss how to use AngularJS to create a text box for autocomplete. This section explains how to use the AngularJS model instructions to develop the auto-completion text box. The auto-completion text box is the simplest user interface for web projects. Here we will develop Google as a text field for automatic completion with AngularJS and Bootstrap. We use the Bootstrap CSS framework for the display suggestion below the text. Here we have defined a text field and under the Javascript code we have saved all country names in matrix format in Javascipt and have executed the AngularJS function in the ng-keyup directive, if we have written something under the text field, then this function It will searches the name of the country for the character that we wrote under the text field of the matrix of the name of the country. When using the AngularJS directive, we displayed this list of filter countries under the HTML tag.


Source Code


autocomplete.php



 <!DOCTYPE html>  
 <html>  
      <head>  
           <title>MyitBuddies Tutorials | Create Autocomplete Textbox In AngularJS Tutorial</title>  
           <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
           <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>  
           <style>  
           li{  
                cursor:pointer;  
           }  
           li:hover  
           {  
                background-color:#f9f9f9;  
           }  
           </style>  
      </head>  
      <body>  
           <br /><br />  
           <div class="container" style="width:500px;">  
                <h3 align="center">Create Autocomplete Textbox In AngularJS Tutorial</h3>  
                <div ng-app="myapp" ng-controller="usercontroller">  
                     <label>Enter Country Name</label>  
                     <input type="text" name="country" id="country" ng-model="country" ng-keyup="complete(country)" class="form-control" />  
                     <ul class="list-group" ng-model="hidethis" ng-hide="hidethis">  
                          <li class="list-group-item" ng-repeat="countrydata in filterCountry" ng-click="fillTextbox(countrydata)">{{countrydata}}</li>  
                     </ul>  
                </div>  
           </div>  
      </body>  
 </html>  
 <script>  
 var app = angular.module("myapp",[]);  
 app.controller("usercontroller", function($scope){  
      $scope.countryList = [  
           "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "France Metropolitan", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard and Mc Donald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao, People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia, The Former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia (Slovak Republic)", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "Spain", "Sri Lanka", "St. Helena", "St. Pierre and Miquelon", "Sudan", "Suriname", "Svalbard and Jan Mayen Islands", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (U.S.)", "Wallis and Futuna Islands", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"  
      ];  
      $scope.complete = function(string){  
           $scope.hidethis = false;  
           var output = [];  
           angular.forEach($scope.countryList, function(country){  
                if(country.toLowerCase().indexOf(string.toLowerCase()) >= 0)  
                {  
                     output.push(country);  
                }  
           });  
           $scope.filterCountry = output;  
      }  
      $scope.fillTextbox = function(string){  
           $scope.country = string;  
           $scope.hidethis = true;  
      }  
 });  
 </script>  

How To Dynamic Dropdown list using AngularJS with PHP

How To Dynamic Dropdown list using AngularJS with PHP

Hello friends, in this tutorial we are going to discuss how you can dynamically populate the dropdown list using AngularJS Framework with PHP programming without page refresh. To discuss this, we define two dropdown lists. In the first selection field we enter the name of the country that was retrieved with AngularJS from the MySQL table, and in the second dropdown list the name of the country of the first country of the selected dropdown list It becomes MySQL table with angled Javascript related to PHP programming language. So in this video we filled in the country selection field with the JavaScript angle function. This function sends a request to the PHP script and this script sends the data and the full country selection field after we want to load the state name of the country selected in the status selection box, we have the function to insert in the change event in the country selection box then If we have selected a country, this function is called and this function sends a request to the PHP script again and sends data back. The JavaScript Angular directive gives us the name of the display status under the status selection field. In this way we have developed a dynamic selection box using an angled JavaScript framework with PHP programming.


Source Code


Database


 --  
 -- Table structure for table `country`  
 --  
 CREATE TABLE IF NOT EXISTS `country` (  
  `country_id` int(11) NOT NULL AUTO_INCREMENT,  
  `country_name` varchar(255) NOT NULL,  
  PRIMARY KEY (`country_id`)  
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;  
 --  
 -- Dumping data for table `country`  
 --  
 INSERT INTO `country` (`country_id`, `country_name`) VALUES  
 (1, 'United States of America'),  
 (2, 'Canada'),  
 (3, 'Australia');  
 -- --------------------------------------------------------  
 --  
 -- Table structure for table `state`  
 --  
 CREATE TABLE IF NOT EXISTS `state` (  
  `state_id` int(11) NOT NULL AUTO_INCREMENT,  
  `country_id` int(11) NOT NULL,  
  `state_name` varchar(255) NOT NULL,  
  PRIMARY KEY (`state_id`)  
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;  
 --  
 -- Dumping data for table `state`  
 --  
 INSERT INTO `state` (`state_id`, `country_id`, `state_name`) VALUES  
 (1, 1, 'Alabama'),  
 (2, 1, 'Arizona'),  
 (3, 1, 'California'),  
 (4, 2, 'Alberta'),  
 (5, 2, 'Manitoba'),  
 (6, 2, 'Ontario'),  
 (7, 3, 'Queensland'),  
 (8, 3, 'Tasmania'),  
 (9, 3, 'Victoria');  

index.php


 <!DOCTYPE html>  
 <html>  
      <head>  
           <title>MyitBuddies Tutorials | How To Dynamic Dropdown list using AngularJS with PHP</title>  
           <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>  
           <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
      </head>  
      <body>  
           <br /><br />  
           <div class="container" style="width:600px;">  
                <h3 align="center">How To Dynamic Dropdown list using AngularJS with PHP</h3>  
                <br />  
                <div ng-app="myapp" ng-controller="usercontroller" ng-init="loadCountry()">  
                     <select name="country" ng-model="country" class="form-control" ng-change="loadState()">  
                          <option value="">Select Country</option>  
                          <option ng-repeat="country in countries" value="{{country.country_id}}">{{country.country_name}}</option>  
                     </select>  
                     <br />  
                     <select name="state" ng-model="state" class="form-control">  
                          <option value="">Select State</option>  
                          <option ng-repeat="state in states" value="{{state.state_id}}">  
                               {{state.state_name}}  
                          </option>  
                     </select>  
                </div>  
           </div>  
      </body>  
 </html>  
 <script>  
 var app = angular.module("myapp",[]);  
 app.controller("usercontroller", function($scope, $http){  
      $scope.loadCountry = function(){  
           $http.get("load_country.php")  
           .success(function(data){  
                $scope.countries = data;  
           })  
      }  
      $scope.loadState = function(){  
           $http.post("load_state.php", {'country_id':$scope.country})  
           .success(function(data){  
                $scope.states = data;  
           });  
      }  
 });  
 </script>  

load_country.php


 <?php  
 //load_country.php  
 $connect = mysqli_connect("localhost", "root", "", "testing");  
 $output = array();  
 $query = "SELECT * FROM country ORDER BY country_name ASC";  
 $result = mysqli_query($connect, $query);  
 while($row = mysqli_fetch_array($result))  
 {  
      $output[] = $row;  
 }  
 echo json_encode($output);  
 ?>  

load_state.php


 <?php  
 //load_state.php  
 $connect = mysqli_connect("localhost", "root", "", "testing");  
 $output = array();  
 $data = json_decode(file_get_contents("php://input"));  
 $query = "SELECT * FROM state WHERE country_id='".$data->country_id."' ORDER BY state_name ASC";  
 $result = mysqli_query($connect, $query);  
 while($row = mysqli_fetch_array($result))  
 {  
      $output[] = $row;  
 }  
 echo json_encode($output);  
 ?>  

How To Create Skeleton Building Loading Effect in PHP with Ajax

How To Create Skeleton Building Loading Effect in PHP with Ajax

Currently we can see on many social networking websites, YouTube or Facebook, when the page was loaded in the browser. Before we load the data on the website, we can determine that the skeleton of loading data has been recognized. For the first time on the website and then after a few seconds, data has been uploaded to the website. In this post we will create this type of skeleton loading screen using the bootstrap library and PHP script with Ajax-JQuery and load data onto the website. In this case, we at make Skeleton Loader do not use jQeury plugins, but use simple CSS to create the skeleton loading screen.

In this tutorial we are going to make Skeleton Loader with Bootstrap. We used this gitup code for this. With this code for loading placeholders, only CSS was used to load content placeholders with animation effects. This style sheet can be used to create simple and flexible skeletons for loading content bookmarks with an animation effect. This library is very user-friendly. You should create a simple style sheet URL in the header of your website and use the CSS class of this library to create a skeleton screen on your website.

So if you're looking for a web tutorial to create a placeholder for Facebook or YouTube style content or a skeleton to load data for your website. This post will then help you to load the Facebook or YouTube style data in simple steps on the skeleton screen. Here we made the Data Load Skeleton Loader use the Placeholder Load Style Sheet Library with Bootstrap. This Skeleton Loader can be used as a loader for the website that looks like Facebook as a data loader or YouTube as a video thumbnail loader, or you can even use it as an image loader or custom content loader. After displaying the Data Skeleton Loader and loading the original data here, we used a PHP script with Ajax. Then for the source code of the loading development of the data loading skeleton screen with Bootstrap and for loading data with PHP script with Ajax jQuery. You will then find the complete source code.


Source Code


Database



--
-- Database: `testing`
--

-- --------------------------------------------------------

--
-- Table structure for table `tbl_post`
--

CREATE TABLE `tbl_post` (
  `id` mediumint(8) UNSIGNED NOT NULL,
  `post_title` text,
  `post_description` text,
  `author` varchar(255) DEFAULT NULL,
  `datetime` datetime DEFAULT NULL,
  `post_image` varchar(150) DEFAULT NULL,
  `post_url` varchar(150) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbl_post`
--
ALTER TABLE `tbl_post`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tbl_post`
--
ALTER TABLE `tbl_post`
  MODIFY `id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT;


index.php



<!DOCTYPE html>
<html>
  <head>
    <title>How To Create Skeleton Building Loading Effect in PHP with Ajax</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
    <link rel="stylesheet" href="https://unpkg.com/placeholder-loading/dist/css/placeholder-loading.min.css">
  </head>
  <body>
    <br />
    <div class="container">
      <h3 align="center">How To Create Skeleton Building Loading Effect in PHP with Ajax</h3>
      <br />
      <div class="card">
        <div class="card-header">Dynamic Data</div>
        <div class="card-body" id="dynamic_content">
          
        </div>
      </div>
    </div>
  </body>
</html>
<script>
  $(document).ready(function(){

    $('#dynamic_content').html(make_skeleton());

    setTimeout(function(){
      load_content(5);
    }, 5000);

    function make_skeleton()
    {
      var output = '';
      for(var count = 0; count < 5; count++)
      {
        output += '<div class="ph-item">';
        output += '<div class="ph-col-4">';
        output += '<div class="ph-picture"></div>';
        output += '</div>';
        output += '<div>';
        output += '<div class="ph-row">';
        output += '<div class="ph-col-12 big"></div>';
        output += '<div class="ph-col-12"></div>';
        output += '<div class="ph-col-12"></div>';
        output += '<div class="ph-col-12"></div>';
        output += '<div class="ph-col-12"></div>';
        output += '</div>';
        output += '</div>';
        output += '</div>';
      }
      return output;
    }

    function load_content(limit)
    {
      $.ajax({
        url:"fetch.php",
        method:"POST",
        data:{limit:limit},
        success:function(data)
        {
          $('#dynamic_content').html(data);
        }
      })
    }

  });
</script>


fetch.php



<?php

//fetch.php;

$connect = new PDO("mysql:host=localhost; dbname=testing", "root", "");

if(isset($_POST['limit']))
{
 $query = "
 SELECT * FROM tbl_post 
 ORDER BY id DESC 
 LIMIT ".$_POST["limit"]."
 ";

 $statement = $connect->prepare($query);

 $statement->execute();

 $result = $statement->fetchAll();

 $output = '';

 foreach($result as $row)
 {
  $output .= '
  <div class="row">
   <div class="col-md-4">
    <img src="images/'.$row["post_image"].'" class="img-thumbnail" />
   </div>
   <div class="col-md-8">
    <h2><a href="'.$row["post_url"].'">'.$row["post_title"].'</a></h2>
    <br />
    <p>'.$row["post_description"].'</p>
   </div>
  </div>
  <hr />
  ';
 }

 echo $output;
}

?>


Tuesday, February 4, 2020

AngularJS-File Upload with PHP Script

AngularJS-File Upload with PHP Script

Hello friends in this post, we will learn how to upload files using AngularJS using PHP programming script. This is my AngularJS tutorial where we learn how to load files with AngularJS with PHP without refreshing the page. In this we load the image and save it in the folder, we have also saved the name of the image in the database table and retrieve the data from the database image and display it on the website with AngularJS. If you are looking for a tutorial in AngularJS to upload images with PHP code to the server. If you are working on a web project based on AngularJS with back-end like PHP and want to add an image loading function in this project, you can follow this tutorial to load angled javascript images with PHP as a server. When we have selected an image, the image is successfully uploaded to the server and also displayed on the website. So this is my tutorial on loading files with JavaScript angle code using PHP script. In this tutorial we learned how to create a custom JavaScript directive to upload files to the server. In this directive, we saved data from selected files and executed the file load function and used this data from selected files in the file load function and we added it to the form data object and the form data object data is displayed using the http publishing method sent to the server and we need to write the php code to upload the file to the server, and when the file is uploaded to the server, the file name is also inserted into the data table. After you have carried out the selection function, you can call up image data from the data table and display images on our site. This is all we are discussing in this video that we are adding to this post.


Source Code


Database


 --  
 -- Table structure for table `tbl_images`  
 --  
 CREATE TABLE IF NOT EXISTS `tbl_images` (  
  `id` int(11) NOT NULL AUTO_INCREMENT,  
  `name` varchar(255) NOT NULL,  
  PRIMARY KEY (`id`)  
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;  
 --  
 -- Dumping data for table `tbl_images`  
 --  

index.php


 <!DOCTYPE html>  
 <html>  
      <head>  
           <title>MyitBuddies Tutorials  | AngularJS-File Upload with PHP Script</title>  
           <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
           <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>  
      </head>  
      <body>  
           <br />  
           <h3 align="center">AngularJS-File Upload with PHP Script</h3><br />  
           <br />  
           <div class="container" ng-app="myapp" ng-controller="myController" ng-init="select()">  
                <div class="col-md-4">  
                     <input type="file" file-input="files" />  
                </div>  
                <div class="col-md-6">  
                     <button class="btn btn-info" ng-click="uploadFile()">Upload</button>  
                </div>  
                <div style="clear:both"></div>  
                <br /><br />  
                <div class="col-md-3" ng-repeat="image in images">  
                     <img ng-src="upload/{{image.name}}" width="200" height="200" style="padding:16px; border:1px solid #f1f1f1; margin:16px;" />  
                </div>  
           </div>  
      </body>  
 </html>  
 <script>  
 var app = angular.module("myapp", []);  
 app.directive("fileInput", function($parse){  
      return{  
           link: function($scope, element, attrs){  
                element.on("change", function(event){  
                     var files = event.target.files;  
                     //console.log(files[0].name);  
                     $parse(attrs.fileInput).assign($scope, element[0].files);  
                     $scope.$apply();  
                });  
           }  
      }  
 });  
 app.controller("myController", function($scope, $http){  
      $scope.uploadFile = function(){  
           var form_data = new FormData();  
           angular.forEach($scope.files, function(file){  
                form_data.append('file', file);  
           });  
           $http.post('upload.php', form_data,  
           {  
                transformRequest: angular.identity,  
                headers: {'Content-Type': undefined,'Process-Data': false}  
           }).success(function(response){  
                alert(response);  
                $scope.select();  
           });  
      }  
      $scope.select = function(){  
           $http.get("select.php")  
           .success(function(data){  
                $scope.images = data;  
           });  
      }  
 });  
 </script>  

upload.php


 <?php  
 $connect = mysqli_connect("localhost", "root", "", "testing");  
 if(!empty($_FILES))  
 {  
      $path = 'upload/' . $_FILES['file']['name'];  
      if(move_uploaded_file($_FILES['file']['tmp_name'], $path))  
      {  
           $insertQuery = "INSERT INTO tbl_images(name) VALUES ('".$_FILES['file']['name']."')";  
           if(mysqli_query($connect, $insertQuery))  
           {  
                echo 'File Uploaded';  
           }  
           else  
           {  
                echo 'File Uploaded But not Saved';  
           }  
      }  
 }  
 else  
 {  
      echo 'Some Error';  
 }  
 ?>  

select.php


 <?php  
 $connect = mysqli_connect("localhost", "root", "", "testing");  
 $output = '';  
 $query = "SELECT * FROM tbl_images ORDER BY id DESC";  
 $result = mysqli_query($connect, $query);  
 while($row = mysqli_fetch_array($result))  
 {  
      $output[] = $row;  
 }  
 echo json_encode($output);  
 ?>  

How To Update / Edit Mysql Table Data Using AngularJS Tutorial with PHP

How To Update / Edit Mysql Table Data Using AngularJS Tutorial with PHP

Hello friends in this blog, we will learn how to update or edit data from the MySQL table using Javascript with PHP script. In the previous post, we learned how to get or select data from the MySQL database table and display that data on the website without refreshing the page. However, we have taken a step like editing pasted data using PHP and the Angular Javascript Framework. If you have worked on a project using Angular Javascipt Framework with PHP and are working with form data, you must update the data that you have inserted into the system at this point. How to update form data with Angular Javascript with PHP programming without page refresh event. With the help of the Angular Javascript directive we can update the data of the mysql table with the PHP code of the operation on the back and the data on the front with the Angular Javascript function without a page update event. So this is my tutorial on updating MySQL data with pointed Javascript in PHP language. In this blog, we performed a data update function with three arguments. When the user clicks on the text box, the update button is full of data and we wrote the PHP code to update the data. We also explained how changes can be made. We also discussed the label of the button according to the requirements and finally and very important things like the required field validation in this video attached to this publication.


Source Code


index.php


 <!DOCTYPE html>  
 <!-- index.php !-->  
 <html>  
      <head>  
           <title>MyitBuddies Tutorials | How To Update / Edit Mysql Table Data Using AngularJS Tutorial with PHP  / Edit Mysql Table Data</title>  
           <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
           <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>  
      </head>  
      <body>  
           <br /><br />  
           <div class="container" style="width:500px;">  
                <h3 align="center">How To Update / Edit Mysql Table Data Using AngularJS Tutorial with PHP  </h3>  
                <div ng-app="myapp" ng-controller="usercontroller" ng-init="displayData()">  
                     <label>First Name</label>  
                     <input type="text" name="first_name" ng-model="firstname" class="form-control" />  
                     <br />  
                     <label>Last Name</label>  
                     <input type="text" name="last_name" ng-model="lastname" class="form-control" />  
                     <br />  
                     <input type="hidden" ng-model="id" />  
                     <input type="submit" name="btnInsert" class="btn btn-info" ng-click="insertData()" value="{{btnName}}"/>  
                     <br /><br />  
                     <table class="table table-bordered">  
                          <tr>  
                               <th>First Name</th>  
                               <th>Last Name</th>  
                               <th>Update</th>  
                          </tr>  
                          <tr ng-repeat="x in names">  
                               <td>{{x.first_name}}</td>  
                               <td>{{x.last_name}}</td>  
                               <td><button ng-click="updateData(x.id, x.first_name, x.last_name)" class="btn btn-info btn-xs">Update</button></td>  
                          </tr>  
                     </table>  
                </div>  
           </div>  
      </body>  
 </html>  
 <script>  
 var app = angular.module("myapp",[]);  
 app.controller("usercontroller", function($scope, $http){  
      $scope.btnName = "ADD";  
      $scope.insertData = function(){  
           if($scope.firstname == null)  
           {  
                alert("First Name is required");  
           }  
           else if($scope.lastname == null)  
           {  
                alert("Last Name is required");  
           }  
           else  
           {  
                $http.post(  
                     "insert.php",  
                     {'firstname':$scope.firstname, 'lastname':$scope.lastname, 'btnName':$scope.btnName, 'id':$scope.id}  
                ).success(function(data){  
                     alert(data);  
                     $scope.firstname = null;  
                     $scope.lastname = null;  
                     $scope.btnName = "ADD";  
                     $scope.displayData();  
                });  
           }  
      }  
      $scope.displayData = function(){  
           $http.get("select.php")  
           .success(function(data){  
                $scope.names = data;  
           });  
      }  
      $scope.updateData = function(id, first_name, last_name){  
           $scope.id = id;  
           $scope.firstname = first_name;  
           $scope.lastname = last_name;  
           $scope.btnName = "Update";  
      }  
 });  
 </script>  

insert.php


 <?php  
 //insert.php  
 $connect = mysqli_connect("localhost", "root", "", "testing");  
 $data = json_decode(file_get_contents("php://input"));  
 if(count($data) > 0)  
 {  
      $first_name = mysqli_real_escape_string($connect, $data->firstname);       
      $last_name = mysqli_real_escape_string($connect, $data->lastname);  
      $btn_name = $data->btnName;  
      if($btn_name == "ADD")  
      {  
           $query = "INSERT INTO tbl_user(first_name, last_name) VALUES ('$first_name', '$last_name')";  
           if(mysqli_query($connect, $query))  
           {  
                echo "Data Inserted...";  
           }  
           else  
           {  
                echo 'Error';  
           }  
      }  
      if($btn_name == 'Update')  
      {  
           $id = $data->id;  
           $query = "UPDATE tbl_user SET first_name = '$first_name', last_name = '$last_name' WHERE id = '$id'";  
           if(mysqli_query($connect, $query))  
           {  
                echo 'Data Updated...';  
           }  
           else  
           {  
                echo 'Error';  
           }  
      }  
 }  
 ?>  

10 Performance Optimization Tips And Ideas for Laravel

10 Performance Optimization Tips And Ideas for Laravel

Laravel is considered the best PHP system of 2017 released in 2011. At this point, if you are trying to become a PHP developer, you have learned something about Laravel. Discover how you can assert yourself in the main structure in recent years. In addition to the various highlights it offers, it is most important for developers and organizations to control the intensity of Laravel's performance development.

There are two key factors that determine the success of any business application development and development. You can also hire a Laravel developer. In these circumstances, ensuring the display of the Laravel application is critical that every developer should be able to broadcast it to their customers. In most cases, management information systems that fundamentally support management levels must be fast and consistently efficient.


Tips for Laravel Performance Optimization


The Maximum Number of plugin


Using too many modules for different highlights and functions is one of the most important reasons for the exceptionally moderate speed of your website. You can localize countless accessible modules for your Laravel development. These add-ons consist of a variety of libraries and documents that have more time to load. To improve development with Laravel Performance Optimization, it is important to provide add-ons that are somewhat complicated in the company.


Use Eager Loading


Laravel uses Eloquent ERM to easily perform (execute, get, update, delete) CRUD tasks. In this way, object models with database tables are provided to support and manage database collaboration. At present, this can lead to a variety of questions and make exposure difficult. It's even easier and more useful to use the fearful stack approach. As you prepare for enthusiastic stacking questions, you can always retrieve the models of items related to them.


Use the most recent version of PHP


Once you use the latest form of PHP in your company, you have the option to see updates regarding how it is running in the company. Therefore, you need to use the latest version of PHP for applications.


Use Packages Wisely


GitHub, like other administrators who simplify the code, offers various Laravel packages for use. If you use such Laravel packages, you will find a decent pace, an additional utility for your Laravel site. Therefore, your application works best if you use a controlled number of packages in your application.


Setup Caching


Here you can reserve all your construction documents. The structure will stack this order quickly. You should only use this job during project development. The configuration options change with the development of the application. And you have to use this address to run the project in local development.


Profile Queries


For the development of Laravel we have to display your application. For a similar explanation, it is important that you monitor several questions and see how they work. When you realize that you can examine the areas that should be rationalized. You can use profile packs as a debug if these queries are observed and executed on every page.


Use JIT Compilers


It is not possible for PCs to understand PHP locally. It is not possible to run PHP through the machines to sort the bytecode. For a similar explanation, we use the Zend motor rotor for work. Zend Engine decrypts the existing PHP entries and then executes the C schedules. This means that the server controls a PHP record and needs an AST parser to switch to tokens and then decrypt them. Regardless of whether you get a similar result, you must definitely record it every time.


Static Files use CDN


You must improve the appearance of your Laravel application in order to load static resources with the CDN server. When a client opens an application, the data is transferred from the CDN to the client. In this sense, page loading speed will increase significantly and customers will be offered a superior experience. For this to work, you need to represent the static elements that are available in this application.


Use of Artisan Commands


Craft management is an extremely useful tool that accompanies Laravel and is used by engineers to improve the presentation of the website. This can be particularly valuable for the situation in which Laravel's engineer tries to think of countless designs and courses. With this in mind, the designer could make a reservation. This is a simple ad. Instead of stacking up the original item, Laravel quickly accumulates.

If you don't, Laravel doesn't care about the progress you've made at this point since he stacked them in the store. Also reserve customer information, scopes and settings as this can reduce the number of SQL queries. If the information is converted, you must discredit the reservation. You should also have Forge send content with instructions on how to book your courses, visits, and settings.


upgrade your Database


If you improve the database in Laravel, you can remove all unnecessary short records that are available there. You can also take out the reservation and the old reinforcements stored there. This will help and speed up and execute the database. This toolbar shows the SQL requests used by the page and the amount of memory they use.