Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android没有通过PHP echo显示消息_Php_Android - Fatal编程技术网

Android没有通过PHP echo显示消息

Android没有通过PHP echo显示消息,php,android,Php,Android,基本上,在我的android应用程序中,有两个字段需要用户填写。一个是必须的,另一个是可选的 我的PHP脚本: <?php // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $db = new DB_CONNECT(); if(isset($_POST['smsCode'])){ $smsCo

基本上,在我的android应用程序中,有两个字段需要用户填写。一个是必须的,另一个是可选的

我的PHP脚本:

<?php 
    // include db connect class
    require_once __DIR__ . '/db_connect.php';

    // connecting to db
    $db = new DB_CONNECT();

    if(isset($_POST['smsCode'])){
            $smsCode = $_POST['smsCode'];
            $query_search = "SELECT * FROM userrequests WHERE smsCode='".$smsCode."'";
            $query_exec = mysqli_query($db->getConnection(),$query_search) or die(mysqli_error($db->getConnection()));;
            $row = mysqli_num_rows($query_exec);
            //echo $rows;
            if($row == 0) {
                echo "Invalid SMS Code";
            }else{
                //Authentication code is correct
                //echo "Code matched";
                $userName = $_POST['userName'];
                $userContact = $_POST['userContact'];
                $userAddress = $_POST['userAddress'];
                $userStore = $_POST['userStore'];
                $userRequest = $_POST['userRequest'];
                $userTime = $_POST['userTime'];
                $sql_insert = "INSERT INTO confirmedrequest(userName,smsCode,contactNumber,userAddress,storeList,timeFrame,requestBody) VALUES ('$userName','$smsCode','$userContact','$userAddress','$userStore','$userTime','$userRequest')";
                $sql_exec = mysqli_query($db->getConnection(),$sql_insert) or die(mysqli_error($db->getConnection()));
                if(isset($_POST['promoCode'])){
                    $promoCode = $_POST['promoCode'];
                    $query_search1 = "SELECT * FROM promocodetable WHERE promoCode='".$promoCode."'";
                    $query_exec1 = mysqli_query($db->getConnection(),$query_search1) or die(mysqli_error($db->getConnection()));;
                    $row1 = mysqli_num_rows($query_exec1);
                    if($row1==0){
                     //do nothing
                    }else{
                        echo "Promo code and sms code matched";
                        $userName = $_POST['userName'];
                        $userContact = $_POST['userContact'];
                        $userAddress = $_POST['userAddress'];
                        $userStore = $_POST['userStore'];
                        $userRequest = $_POST['userRequest'];
                        $userTime = $_POST['userTime'];
                        $promoCode = $_POST['promoCode'];
                        $smsCode = $_POST['smsCode'];
                        $sql_insert1 = "INSERT INTO promorequest(userName,smsCode,contactNumber,userAddress,storeList,timeFrame,requestBody,promoCode,smsCode) VALUES ('$userName','$smsCode','$userContact','$userAddress','$userStore','$userTime','$userRequest','$promoCode','$smsCode')";
                        $sql_exec1 = mysqli_query($db->getConnection(),$sql_insert1) or die(mysqli_error($db->getConnection()));
                    }
                }else{
                    echo "Code matched";
                }
            }
    }else{
        echo "Empty Code";
    }

是否将
smsCode
存储为数据库中的INT?@M.Doye其存储为文本
httpclient=new DefaultHttpClient();
            httppost= new HttpPost("www.something.com/something.php"); // make sure the url is correct.
            //add your data
            nameValuePairs = new ArrayList<NameValuePair>(1);
            // Always use the same variable name for posting i.e the android side variable name and php side variable name should be similar,
            //int smsNum = Integer.parseInt(smsCode.getText().toString());

            nameValuePairs.add(new BasicNameValuePair("smsCode",smsCode.getText().toString()));
            nameValuePairs.add(new BasicNameValuePair("promoCode",promoCode.getText().toString()));// $Edittext_value = $_POST['Edittext_value'];
            nameValuePairs.add(new BasicNameValuePair("userName",confirmName));
            nameValuePairs.add(new BasicNameValuePair("userContact",confirmContact));
            nameValuePairs.add(new BasicNameValuePair("userAddress",confirmAddress));
            nameValuePairs.add(new BasicNameValuePair("userStore",confirmStore));
            nameValuePairs.add(new BasicNameValuePair("userRequest",confirmRequest));
            nameValuePairs.add(new BasicNameValuePair("userTime",confirmTime));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            //Execute HTTP Post Request
            //response=httpclient.execute(httppost);

            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            final String response = httpclient.execute(httppost, responseHandler);

            runOnUiThread(new Runnable() {
                public void run() {
                    Log.i("PHP Response: ", response);
                    pDialog.dismiss();
                }
            });
            if(response.equalsIgnoreCase("Promo code and sms code matched")) {
                runOnUiThread(new Runnable() {
                    public void run() {
                        Toast.makeText(DisplayInformation.this, "Promo Code Matched", Toast.LENGTH_SHORT).show();
                        Intent myintent = new Intent(DisplayInformation.this, Confirmation.class);

                        myintent.putExtra("confirmID", smsCode.getText().toString());
                        myintent.putExtra("confirmPromo",promoCode.getText().toString());
                        myintent.putExtra("displayName", confirmName);
                        myintent.putExtra("displayContact", confirmContact);
                        myintent.putExtra("displayAddress", confirmAddress);
                        myintent.putExtra("displayStore", confirmStore);
                        myintent.putExtra("displayTime", confirmTime);
                        myintent.putExtra("displayRequest", confirmRequest);
                        myintent.putExtra("displayFee", String.valueOf(deliveryFee));
                        startActivity(myintent);

                    }
                });
            }

            if(response.equalsIgnoreCase("Code matched")){
                runOnUiThread(new Runnable() {
                    public void run() {
                        Toast.makeText(DisplayInformation.this,"Code Matched", Toast.LENGTH_SHORT).show();
                        Intent myintent = new Intent(DisplayInformation.this, Confirmation.class);

                        myintent.putExtra("confirmID",smsCode.getText().toString());
                        myintent.putExtra("displayName",confirmName);
                        myintent.putExtra("displayContact",confirmContact);
                        myintent.putExtra("displayAddress",confirmAddress);
                        myintent.putExtra("displayStore",confirmStore);
                        myintent.putExtra("displayTime",confirmTime);
                        myintent.putExtra("displayRequest",confirmRequest);
                        myintent.putExtra("displayFee",String.valueOf(deliveryFee));
                        startActivity(myintent);

                    }
                });


                //startActivity(new Intent(AndroidPHPConnectionDemo.this, UserPage.class));
            }else{
                showAlert();//testing bitbuckettt
            }





    ?>