AngularJS Form submission and Retrieve All Inputs Values using PHP

AngularJS Form submission and Retrieve All Inputs Values using PHP

In this Post We Will Explain About is AngularJS Form submission and Retrieve All Inputs Values using PHP With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJS POST request with PHP Creating login form Example

In this post we will show you Best way to implement angularjs with php – Simple form submission, hear for Retrieve all inputs values from a form AngularJS with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  vuejs Autocomplete textbox PHP MySQLi

AngularJS POST request with PHP

In this Example,First of all Add or Inluce External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priorty set.After that Include your relavant CSS Class.

index.html page

We can Create a HTML form to all the data submit and save to database using PHP

<!DOCTYPE html>
<html ng-app="liveApp">
    <head>
        <title>simple form Submit with AngualrJS using PHP</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
        <script src="/js/angular.js" ></script>
        <script src="/js/formjs.js"></script>
    </head> 

    <body>

        <div ng-controller="liveCtrl">
            <form  name="studForm"  class="well form-search"   >
                
                <input type="text" ng-model="name" class="input-medium search-query" placeholder="Enter your Name" required>
                <input type="email" ng-model="email" class="input-medium search-query" placeholder="Enter your Email" required>
                <input type="text" ng-model="comments" class="input-medium search-query" placeholder="Enter your comments" required>
                <button type="submit" class="btn" ng-click="live_form(studForm.$valid)"  ng-disabled="studForm.$invalid">Submit </button>
		
            </form>
            <pre ng-model="response">
                {{response}}
            </pre>
        </div>
    </body>

</html>

formjs.js

var app = angular.module('liveApp', []);


app.controller("liveCtrl", ['$scope', '$http', function($scope, $http) {
        $scope.url = 'submit.php';

        $scope.live_form = function(isValid) {


            if (isValid) {
              

                $http.post($scope.url, {"name": $scope.name, "email": $scope.email, "comments": $scope.comments}).
                        success(function(data, status) {
                            console.log(data);
                            $scope.status = status;
                            $scope.data = data;
                            $scope.response = data; 
                        })
            }else{
                
                  alert('YourForm is not valid');
            }

        }

    }]);
[/php


<p> For that we can use get all the post value the below source code:</p>
[php]
$post_date = file_get_contents(“php://input”);
$data = json_decode($post_date);

submit.php

Below is the some mysql query to save data to database .And then We Are just printing some all the html form values which we will get from the HTML Data form for illustration. Like as a php submission form

READ :  AngularJs Forms Submit Post Method Example

<?php

$data_post = file_get_contents("php://input");
$get_data = json_decode($data_post);

echo "Name : ".$get_data->name."n";
echo "Email : ".$get_data->email."n";
echo "comments : ".$get_data->comments."n";

//simple put in mysql database

?>

You are Most welcome in my youtube Channel Please shubscibe my channel. and give me feedBackMore Details……
Angularjs Example

Example

I hope you have Got What is Retrieve all inputs values from a form AngularJS And how it works.I would Like to have FeaeBack From My Blog(infinityknow.com) readers.Your Valuable FeedBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Add a Comment

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