Javascript 创建一个PHP表单以提交带有Angular网站的电子邮件

Javascript 创建一个PHP表单以提交带有Angular网站的电子邮件,javascript,php,angularjs,forms,http-status-code-404,Javascript,Php,Angularjs,Forms,Http Status Code 404,我目前正在尝试创建一个简单的联系人表单,使用PHP脚本发送电子邮件。单击表单中的submit按钮时,我在控制器中调用下面的函数。我收到一个404错误的post请求。当我执行get请求时,它工作,但post返回404 这是发布到php表单以发送电子邮件的正确方式吗?还有别的方法吗?谢谢 $scope.url = 'feedback.php'; $scope.update = function(new_message){ $http.post($scope.url, new_message)

我目前正在尝试创建一个简单的联系人表单,使用PHP脚本发送电子邮件。单击表单中的submit按钮时,我在控制器中调用下面的函数。我收到一个404错误的post请求。当我执行get请求时,它工作,但post返回404

这是发布到php表单以发送电子邮件的正确方式吗?还有别的方法吗?谢谢

$scope.url = 'feedback.php';
$scope.update = function(new_message){
    $http.post($scope.url, new_message).success(function (data, status) {
           if (data.success) {
                 $window.alert("Thank you! Your message has been sent.");
            }      
        }).error(function (data, status) {
            $window.alert("Sorry, there was a problem!");
        });
  }
PHP代码如下:

<?php
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;
  $name = $_REQUEST['name'] ;

  $from="From: $name<$email>\r\nReturn-path: $email"; 
        $subject="Message sent using your contact form"; 
        mail("emailredacted@gmail.com", $subject, $message, $from);

        header("Location: http://localhost:3000/#/about");
?>

表格如下:

<form class="col s12" id="email-form">
      <div class="row">
        <div class="input-field col s12">
          <i class="material-icons prefix">account_circle</i>
          <input id="name" type="text" class="validate" ng-model="user.name">
          <label for="name" class="form-label">Name</label>
        </div>
        <div class="input-field col s12">
          <i class="material-icons prefix">email</i>
          <input id="email" type="email" class="validate" ng-model="user.email">
          <label for="email" data-error="wrong" data-success="right">Email</label>
        </div><br><br><br>
         <div class="input-field col s12">
          <i class="material-icons prefix">message</i>
          <textarea id="message" class="materialize-textarea" ng-model="user.message"></textarea>
          <label for="message">Message</label>
        </div>
      </div>
      <a class="waves-effect waves-light btn" id="submit-button" ng-click="update(user)"><i class="material-icons left">check circle</i>Submit</a>
    </form>

会计圈
名称
电子邮件
电子邮件



消息 消息 检查循环提交
响应中定义了
数据。成功
在哪里?我找不到它,我把那个部分改成了if(数据)——我没有达到那个条件,因为我每次都会得到错误部分。post请求未成功。响应中定义的
数据在哪里。成功
?我找不到它,我把那个部分改成了if(数据)——我没有达到那个条件,因为我每次都会得到错误部分。post请求未成功。