I'm pretty new in angular.
i created a modal window to user share story and after that show it in body:
html
<button class="btn btn-primary new-story" ng-click="showPopup()">New Story</button>
<div class="wroteStory img-rounded" ng-repeat="story in sentCompose">
<h1 class="s-label"><i><label for="subject">Subject :</label></i></h1>
<h5>{{story.subject}}</h5>
<h1 class="s-label"><i><label for="body">Full Story :</label></i></h1>
<h6>{{story.body}}</h6>
<button class="btn btn-danger" ng-click="remove($index)"> Delete </button>
<hr/>
</div>
js
app.controller('aboutController', function($scope,ngProgress) {
$scope.popupVisible = false;
$scope.showPopup = function(){
$scope.popupVisible = true;
$scopeposeStory = {};
}
$scope.closePopup = function(){
$scope.popupVisible = false;
}
$scopeposeStory = {};
$scope.sentCompose = [];
$scope.sendStory = function() {
$scope.sentCompose.push($scopeposeStory);
$scope.popupVisible = false;
$http.post("insert.php", data).success(function(data, status, headers, config){
});
};
i want to save data from this form to database ? Thx in advance
I'm pretty new in angular.
i created a modal window to user share story and after that show it in body:
html
<button class="btn btn-primary new-story" ng-click="showPopup()">New Story</button>
<div class="wroteStory img-rounded" ng-repeat="story in sentCompose">
<h1 class="s-label"><i><label for="subject">Subject :</label></i></h1>
<h5>{{story.subject}}</h5>
<h1 class="s-label"><i><label for="body">Full Story :</label></i></h1>
<h6>{{story.body}}</h6>
<button class="btn btn-danger" ng-click="remove($index)"> Delete </button>
<hr/>
</div>
js
app.controller('aboutController', function($scope,ngProgress) {
$scope.popupVisible = false;
$scope.showPopup = function(){
$scope.popupVisible = true;
$scope.poseStory = {};
}
$scope.closePopup = function(){
$scope.popupVisible = false;
}
$scope.poseStory = {};
$scope.sentCompose = [];
$scope.sendStory = function() {
$scope.sentCompose.push($scope.poseStory);
$scope.popupVisible = false;
$http.post("insert.php", data).success(function(data, status, headers, config){
});
};
i want to save data from this form to database ? Thx in advance
Share Improve this question asked Oct 5, 2014 at 22:15 user3856699user3856699 7- 2 This is too broad. Just Google PHP and database and you'll get plenty of tutorial. – John Conde Commented Oct 5, 2014 at 22:16
- please help if you can , i've google it already and can't made it – user3856699 Commented Oct 5, 2014 at 22:18
- 4 If you can't follow any of the tutorials posted on the Internet already, how will you follow one posted here? – John Conde Commented Oct 5, 2014 at 22:19
- because they are not simple as i want , as i said before i'm new in angular – user3856699 Commented Oct 5, 2014 at 22:22
- Why do you think it would be any simpler here? Also, if you read my first ment again, you'll notice I said PHP and database. I didn't mention Angular. Angular cannot interact with a database. – John Conde Commented Oct 5, 2014 at 22:52
2 Answers
Reset to default 0first you should be able to create a db in mysql and creat a table for that .
then you should be able to connect them with php like this :
$host = "localhost";
$user = "angular";
$pass = "angular";
$database = "angular";
$con = mysql_connect($host,$user,$pass);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db($database,$con);
With limited information you provided, i will try to help you on this. When you ask questions, please show what output your are getting, what your debugging says. It will be helpful for others to understand your problem and suggest you some solution. Here is my suggestions
1) I could not see scope of your $http.post("insert.php", **data**)
data variable make sure that you have serialized data in it.
2) Check in firebug whether your request is being sent or not. If you can see the request then see what is the response you are getting
3) As you have success handler always have a error handler for any Ajax call, it is a best practice and saves lot of your time in debugging
My suggestions are based on assumption that your insert.php
is tested for inserting data properly. If not you have to follow what John Conde told