这段代码中是否存在某种安全问题?结果没有得到

时间:2017-05-17 07:33:32

标签: php sql api web service

下面我要描述我的代码。代码的所有连接和流程都是完美的但是当$ sql查询在$ result变量中得到结果为null时,请给我一个正确的解决方案。

这是服务器端远程通知的代码。

<?php

error_reporting(0);
 include_once('PushNotification.php');

    // Message payload
    $msg_payload = array (
        'mtitle' => 'Signature Request',
        'mdesc' => 'Please Sign The Document.',
    );


if( $_SERVER['REQUEST_METHOD']=='POST' && $_POST['signers']){  //pass parameter through url

    $signer_array = $_POST['signers'];
    $conn = mysql_connect('pixster.pixsterstudio.com','xxxx','xxxx') or die('Cannot connect to the DB');
        mysql_select_db('easy_sign',$conn);

    for ($i = 0; $i < count($signer_array); $i++) {


        $signer = ($signer_array[$i]);
        //$signer = 'pixstertest@gmail.com';
        $sql = "SELECT device_token FROM register WHERE email = '$signer'";
        $result = mysqli_query($conn, $sql);

        if (mysqli_num_rows($result) != 0) {
                while($row = mysqli_fetch_assoc($result)) {

                    $deviceToken = $row["device_token"];
                    PushNotifications::iOS($msg_payload, $deviceToken);
                    $json = array('status'=>1,'Message'=>"Send Notification");
                }

        }
        else{
            $json = array('status'=>0,'Message'=>$sql);
        }



       }
}



 echo json_encode($json);   

?>

0 个答案:

没有答案