Simple Form Submit In AngularJs with PHP

Simple Form Submit In AngularJs with PHP

Today, We want to share with you Simple Form Submit In AngularJs with PHP.
In this post we will show you Simple Form Submit In AngularJs with PHP, hear for Simple Form Submit In AngularJs with PHP we will give you demo and example for implement.
In this post, we will learn about Simple Form Submit In AngularJs with PHP with an example.

READ :  vuejs Authentication - vue sessionstorage and localstorage

Simple Form Submit In AngularJs with PHP

Which is the best PHP framework for making an angularJs Web App’s?

Simple AngularJS is a client side(browser side) JavaScript library(SPA’s) while PHP is a server side programming language.an AngularJs always run on client side(Browser side) , if you want to build an web site in php i will advised to laravel will be the best choice to create a web app’s. then we can easily use Restful api and website in laravel and also there is lots of couple of advantages of using laravel php framework.

AngularJs is a client side(browser side) framework so there is no any connection between angularJs and php framework.

READ :  Angularjs Table Rows Dynamically Example

AngularJS Submit From Controller with PHP

index.html

[php]

Angularjs Insert update delete using php mysql with infinityknow.com

                {{result}}
            

infinityknow.com

[/php]

form_data.js

[html]
// define module
var app = angular.module(‘submitFormExample’, []);

//define controller
app.controller(“submitFormCtrl”, [‘$scope’, ‘$http’, function($scope, $http) {
$scope.url = ‘do_submit.php’; // send or post data in this page
$scope.formsubmit = function(isValid) {
if (isValid) {

// all post data and valid form using angularjs
$http.post($scope.url, {“name”: $scope.name, “email”: $scope.email, “message”: $scope.message}).
success(function(data, status) {
console.log(data); //console print data
$scope.status = status; // store status
$scope.data = data; // all data store in this var
$scope.result = data; // display result from server to response in our


HTML element
})
}else{

READ :  Top AngularJS Interview Questions and answers

alert(‘my html Form is not valid :plz valid data enter’);
}
}
}]);
[/html]

do_submit.php

->Simple saving to database connection and excute query->excute or save query
->now simple i am just printing all parameter’s the values

[php]
$post_date = file_get_contents(“php://input”);
$data = json_decode($post_date);
echo “Your Good Name : “.$data->name.”\n”;
echo “Your Professtional Email : “.$data->email.”\n”;
echo “your Suggest Message : “.$data->message.”\n”;
[/php]

Download

Leave a Reply

Your email address will not be published. Required fields are marked *