AngularJs http post Request To PHP json

Today, We want to share with you AngularJs http post Request To PHP json.In this post we will show you how to send data from angularjs to php, hear for AngularJs Simple Example: Post Data to PHP page we will give you demo and example for implement.In this post, we will learn about how to call php function from angularjs controller with an example.

AngularJs http post Request To PHP json

There are the Following The simple About AngularJs http post Request To PHP json Full Information With Example and source code.

As I will cover this Post with live Working example to develop Posting Form Data With $http In AngularJS, so the How to Submit Form with Validation in AngularJS with PHP for this example is following below.

Step 1: HTML Part

index.html



    
        AngularJs Post Example: pakainfo.com 
        
        
    
    
        
  • {{ error}}
  • {{ r_message}}

Product Submit Form

pakainfo.com

Step 2: PHP Code

simple PHP source Code will be:

pname);
$product_auth = mysql_real_escape_string($data->product_auth);
$shop_key = mysql_real_escape_string($data->shop_key);

$con = mysql_connect('localhost', 'root', '');
mysql_select_db('pakainfo', $con);

$qry_em = 'select count(*) as cnt from products where shop_key ="' . $shop_key . '"';
$qry_res = mysql_query($qry_em);
$res = mysql_fetch_assoc($qry_res);

if ($res['cnt'] == 0) {
    $qry = 'INSERT INTO products (name,pass,shop_key) values ("' . $product_name . '","' . $product_auth . '","' . $shop_key . '")';
    $qry_res = mysql_query($qry);
    if ($qry_res) {
        $my_res_array = my_res_arrayay('r_message' => "Product Created Successfully!!!", 'error' => '');
        $results_json = json_encode($my_res_array);
        print_r($results_json);
    } else {
        $my_res_array = my_res_arrayay('r_message' => "", 'error' => 'Error In inserting record');
        $results_json = json_encode($my_res_array);
        print_r($results_json);
    }
} else {
    $my_res_array = my_res_arrayay('r_message' => "", 'error' => 'Product Already exists with same shop_key');
    $results_json = json_encode($my_res_array);
    print_r($results_json);
}
?>
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about AngularJs http post Request To PHP json.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment