Welcome to Designers Dairy blog here i have posted How to create a Simple Php Login page
without Database
Step1:
HTML Code:
<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.name }}</td>
<td>{{ x.address }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://localhost:8090/basic/output.php")
.success(function (response) {$scope.names = response});
});
</script>
</body>
</html>
Step2:
PHP CODE:
<?php
header("Access-Control-Allow-Origin: *");
header ("Content-type: application/json");
//the example of inserting data with variable from HTML form
//input.php
mysql_connect("localhost", "root", "");//database connection
mysql_select_db("employees");
//inserting data order
$order = "SELECT * FROM `data_employees`";
//declare in the order variable
$result = mysql_query($order); //order executes
while ($results[] = mysql_fetch_array($result, MYSQL_ASSOC));
array_pop($results); //deletes the last element of an array.
echo json_encode($results); // Converting Array to JSON Format
?>
Step3:
Enjoy Folks
without Database
Step1:
HTML Code:
<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.name }}</td>
<td>{{ x.address }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://localhost:8090/basic/output.php")
.success(function (response) {$scope.names = response});
});
</script>
</body>
</html>
Step2:
PHP CODE:
<?php
header("Access-Control-Allow-Origin: *");
header ("Content-type: application/json");
//the example of inserting data with variable from HTML form
//input.php
mysql_connect("localhost", "root", "");//database connection
mysql_select_db("employees");
//inserting data order
$order = "SELECT * FROM `data_employees`";
//declare in the order variable
$result = mysql_query($order); //order executes
while ($results[] = mysql_fetch_array($result, MYSQL_ASSOC));
array_pop($results); //deletes the last element of an array.
echo json_encode($results); // Converting Array to JSON Format
?>
Step3:
Enjoy Folks
No comments:
Post a Comment