AngularJS
からPHP
にデータを送信しようとしています。AngularJSからPHPへのIF-ステートメントのためのデータの、PHPでの適切な構文の送信?
controller.js
からAngularJS
のデータを送信しています。 PHP
でデータを受信しています。データは他の変数にも適しています。
しかし、どの部分が問題なのかわかりません。
私の目標はPHP
を$step_number
と認識し、PHP
のIF文を実行することですが、間違ったデータを送信しても機能します。 PHP
で$step_number
が'2'
であることを意味し
、 場合は、以下に示すように、その後、PHP
でIF文は動作しないはずです。しかし、それは実行されます!
これは、他のデータがPHP
に渡されているときにコードを書き込むための適切な方法だと思いました。
Controller.js
$http.post("../crud/projects_update.php",{
step_number : '1', // This one, I am trying to send, but I don't know whether this is not being sent or the problem is occurred in PHP.
project_id : $scope.project_data.project_id // This works in the PHP. It is well sent.
project_title : $scope.project_data.project_title
}
PHP
require_once 'connect.php';
$data = json_decode(file_get_contents("php://input"));
$step_number = $data->step_number; // This should be received from AngularJS and if the $step_number is not matched in the IF-statement, then the function in { } should not work.
if ($step_number = '1'){
$project_id = $data->project_id;
$project_title = $data->project_title;
$conn->query("UPDATE `projects` SET
`project_title` = '$project_title',WHERE `project_id` = $project_id") or die(mysqli_error());
}
問題が 'IF($ STEP_NUMBER = '1')としてPHPに思わ{'割り当てない比較です。 ($ step_number == 1){'に変更し、' step_number: '1'、 'step_number:1、'に変更してください。 –