Posting from web app to database fails
Posted: Tue Sep 21, 2021 2:36 pm
Using mysql database with PHP and AngularJs in Web App. The console is not throwing any errors. I used ng-model to double bind desc, pric, cat, and title to input tags in the html. Here is my javascript:
Everything is compiling/displaying nicely but it is not posting anything to the database when I do a retrieval from the database. The success alert "HI I AM IN" is also executing.
Here is the PHP
We've used PHP from an android platform with JSON and it has worked, it's just not working for our web app with angular. Help! Thank you! <3
Code: Select all
app.controller('MainController', ['$scope', '$http', function($scope, $http) {
$scope.light = "Light";
var _userId = 44;
$scope.desc = "" ;
$scope.pric = "" ;
$scope.cat = "";
$scope.title = "HERE I AM!";
$scope.sendPost = function() {
var data = $.param({
json: JSON.stringify({
userId: _userId,
price: $scope.pric,
description: $scope.desc,
category: $scope.cat,
postTitle: $scope.title,
photo1: "",
photo2: "",
photo3: "",
tag1: "",
tag2: "",
tag3: ""
})
});
$http.post("http://speffs.one/SPE/post.php", data).success(function(data, status) {
window.alert("HIII I AM IN");
});
};
}]);
Everything is compiling/displaying nicely but it is not posting anything to the database when I do a retrieval from the database. The success alert "HI I AM IN" is also executing.
Here is the PHP
We've used PHP from an android platform with JSON and it has worked, it's just not working for our web app with angular. Help! Thank you! <3