2017-10-17 16 views
0

私はおそらく何か間違っていましたが、JavaScriptからPHPへのデータの解析方法をajaxのように見せてくれましたが、うまく見えましたが、データを送信して更新することは望ましくありません私のデータベース。Ajaxがデータを正しく解析していませんか?

ダイアログボックスが表示され、内部に何も表示されません。

AJAX:

$.ajax({ 
     url: 'updateCredits.php', 
     type: 'GET', 
     data: { 
      credits: totalcash 
     }, 
     success: function(data){ 
      alert(data); 
     } 
    }); 

PHP:

<?php 

require 'steamauth/steamauth.php'; 
include ('steamauth/userInfo.php'); 
include('mysql/config.php'); 

if(isset($_SESSION['steamid'], $_GET["credits"])) { 
    $credits = $_GET['credits']; 
    mysqli_query($db,"UPDATE set credits = credits + '".$credits."' WHERE steamid = '".$steamprofile['steamid']."'"); 
} else { 
echo 'An Error has occurred, this is either due to you not being logged in or something went wrong!'; 

} 

?> 
+1

にスニペット?あなたは成功したことを何もエコーしていません。 また、あなたのコードは[SQL Injection](https://www.owasp.org/index.php/SQL_Injection)の非常に非常に脆弱です。 – ntzm

+0

注:PUTを使用している場合は、更新操作 –

+0

が動作しているはずです正しく。コード内の空のアラートは、DBにエラーやデータがない可能性が高いことを意味します。 –

答えて

0

あなたはPHPから何かを返されていませんが、あなたが起こることを期待しない何を成功

<?php require 'steamauth/steamauth.php'; 
include ('steamauth/userInfo.php'); 
include('mysql/config.php'); 
if(isset($_SESSION['steamid'], $_GET["credits"])) 
{ 
    $credits = $_GET['credits']; mysqli_query($db,"UPDATE set credits = credits + '".$credits."' WHERE steamid = '".$steamprofile['steamid']."'"); 
echo 'Success fully updated'; 
} else { echo 'An Error has occurred, this is either due to you not being logged in or something went wrong!'; } ?> 
関連する問題