Reputation: 1979
My form code is
<form name="myForm" ng-controller="Ctrl" action="form.php" method="POST">
Name: <input name="input" ng-model="userName" name="name" required placeholder="Enter Name"><br>
Email: <input name="email" ng-model="userEmail" name="email" required placeholder="Enter Email"><br>
<input type="submit" name="submit"><br>
<tt>userType = {{userName}}</tt><br>
<tt>userEmail = {{userEmail}}</tt><br>
</form>
My script is
<script >
function Ctrl($scope) {
$scope.userName = '';
$scope.userEmail = '';
}
</script>
form.php code is
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$email = $_POST['email'];
echo $name."<br>";
echo $email."<br>";
}
how to pass form value to php , any idea
Upvotes: 0
Views: 134
Reputation: 555
in ur code above u used name tag twice.. thats y in php code it was not picking up the data.
Upvotes: 0
Reputation: 32357
here is a plunker: http://plnkr.co/edit/fC1GikCS0v1tDVTG37vZ?p=preview
controller
function Ctrl($scope, $http) {
$scope.user = {
name : '',
email: ''
};
$scope.submit = function(user){
$http.post('/form.php', user);
}
}
html
<form name="myForm" ng-controller="Ctrl" ng-submit="submit(user)">
Name: <input type="text" ng-model="user.name"><br>
Email: <input type="email" ng-model="user.email"><br>
<input type="submit" name="submit"><br>
</form>
Upvotes: 1