title: AngularJS: cannot POST to server PHP file (getting 404)
body: <p>Hi All and thanks for your time!
  I am new to AngularJS and currently working on my first form with server side part.
  I am running on VirtualBox, used Yeoman to set up.</p>
  
  <p>my HTML has 2 fields: username and password, that are in turn passed to the js file:</p>
  
  <pre><code>function authUsers($scope, $http) {
  $scope.url = '../api/authUsersService.php'; // The url of our search
  
  // The function that will be executed on button click (ng-click="search()")
  $scope.loginAttempt = function() {
  
      // Create the http post request
      // the data holds the keywords
      // The request is a JSON request.
      alert($scope.session.username);alert($scope.session.password);
      $http.post($scope.url, { "username" : $scope.session.username, "password" : $scope.session.password}).
      success(function(data, status) {
          $scope.status = status;
          $scope.data = data;
          $scope.result = data; // Show result from server in our &lt;pre&gt;&lt;/pre&gt; element
          alert(data);
      })
      .
      error(function(data, status) {
          $scope.data = data || "Request failed";
          $scope.status = status;
          alert(data);         
          alert(status);
      });
  };
  }
  </code></pre>
  
  <p>I am getting the 2 alerts (username, password).
  This file and the HTML itself is under Angular's APP folder. outside the folder, in the same containing folder: I created 'API' folder. this is the file api/authUsersService.php:</p>
  
  <pre><code>&lt;?php
  $data = file_get_contents("php://input");
  
  $objData = json_decode($data);
  
  // Create connection
  $con=mysqli_connect("example.com","peter","abc123","my_db");
  
  // Check connection
  if (mysqli_connect_errno($con))  {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $result = mysqli_query($con, "select userID from authUsers where username = " . $objData-&gt;username . " and password = " . $objData-&gt;password);
  
  if ($result-&gt;num_rows &gt; 0) {
      $row = $result-&gt;fetch_array(MYSQLI_ASSOC);
      echo $row["userID"];
  } else {
      echo "";    
  }
  ?&gt;
  </code></pre>
  
  <p>when the HTML form is submitted, i am getting all the alerts from the controller (js file), including the ".error" ones. the data i am getting inside the error: "cannot post to /api/authUsersService.php" and the status is "404".</p>
  
  <p>i couldn't find any solution. tried an .htaccess in the var\www\http folder, didnt help.
  please help me successfully get to the PHP server code!
  thanks!</p>