Issues in Ethernet Shield with HF Rfid

Hi,
I am working on ethernet shield with hf RFID mfrc522 reader.While I am transferring a RFID tag data to a server then I got a null data transferring in MySQL database.

#include <SPI.h>
#include <MFRC522.h>
#include <Ethernet.h>
#include <Client.h>
//#include <SoftwareSerial.h>

//SoftwareSerial RFID(2, 3);

#define SS_PIN 2
#define RST_PIN 3
MFRC522 mfrc522(SS_PIN, RST_PIN);        // Create MFRC522 instance.

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

const char* host="192.168.1.58";  // numeric IP for server (no DNS) (reduce sketch size)
IPAddress ip(192,168,1,201);      //numeric IP of the ETHERNET shield (STATIC)

EthernetClient client; //Initialize the Ethernet client library(port 80 is HTTP default):

int first=0;
int counter=0;
String data;
String tag;
String result;


void setup() {
        Serial.begin(9600);        // Initialize serial communications with the PC
        
        // disable SD SPI
        pinMode(4, OUTPUT);
        digitalWrite(4, HIGH);
        
        // disable w5100 SPI
        pinMode(10, OUTPUT);
        digitalWrite(10, HIGH);
        
        SPI.begin();                // Init SPI bus
        mfrc522.PCD_Init();        // Init MFRC522 card
        Serial.println("Scan a MIFARE Classic PICC to demonstrate Value Blocks.");
        
        Ethernet.begin(mac, ip); //we used a STATIC address to start ETHERNET
    
        // print your local IP address:
        Serial.print("My IP address: ");
        for (byte thisByte = 0; thisByte < 4; thisByte++) {
        // print the value of each byte of the IP address:
        Serial.print(Ethernet.localIP()[thisByte], DEC);
        Serial.print(".");
        }
        // give the Ethernet shield a second to initialize:
        delay(1000);
        Serial.println("connecting...");
}

void loop() {
  
          // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
//        MFRC522::MIFARE_Key key;
//        for (byte i = 0; i < 6; i++) {
//                key.keyByte[i] = 0xFF;
//        }
//          MFRC522::MIFARE_Key key;
//         for (byte k = 0; k < NR_KNOWN_KEYS; k++) {
//        // Copy the known key into the MIFARE_Key structure
//        for (byte i = 0; i < MFRC522::MF_KEY_SIZE; i++) {
//            key.keyByte[i] = knownKeys[k][i];
//        }
//         }
        // Look for new cards
        if ( ! mfrc522.PICC_IsNewCardPresent()) {
                return;
        }

        // Select one of the cards
        if ( ! mfrc522.PICC_ReadCardSerial()) {
                return;
        }
        // Now a card is selected. The UID and SAK is in mfrc522.uid.
//        Serial.print(F("Tagid:"));
        dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
        Serial.println();  
}

// Helper routine to dump a byte array as hex values to Serial
void dump_byte_array(byte *buffer, byte bufferSize) {

  for (byte i = 0; i < bufferSize; i++) {
    result += String(buffer[i], HEX) + String(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(String(buffer[i] < 0x10 ? " 0" : " "));
    Serial.print(String(buffer[i], HEX));
  }
//        dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
//        // Dump UID
////        Serial.print("Card UID:");
//       for (byte i = 0; i < mfrc522.uid.size; i++) {
//          result += String(mfrc522.uid.uidByte[i], HEX);
//          Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
//          Serial.print(mfrc522.uid.uidByte[i], HEX);
         
              
                
//    int val1=(mfrc522.uid.uidByte[0]);
//    Serial.println(val1);
//    int val2=(mfrc522.uid.uidByte[1]);
//    Serial.println(val2);
//    int val3=(mfrc522.uid.uidByte[2]);
//    Serial.println(val3);
//    int val4=(mfrc522.uid.uidByte[3]);
//    Serial.println(val4);
//    
//    String valA=String(val1);
//    String valB=String(val2);
//    String valC=String(val3);
//    String valD=String(val4);
//    tag=valA+valB+valC+valD;
    Serial.print("result=");
    Serial.print(result);
    Serial.println();
    counter=counter+1;    
    Serial.print(counter); //} 
    Serial.println();

    pinMode(2, OUTPUT);
    digitalWrite(2, HIGH);

   
        // Halt PICC
        mfrc522.PICC_HaltA();

        // Stop encryption on PCD
        mfrc522.PCD_StopCrypto1();
        
        
        
        
                       
    if (counter>first)
    {//delay ifs
    // enable w5100 SPI

     digitalWrite(10, LOW);
    
     data = String("tag=") + result;
       
    if (client.connect(host, 80)) { //start of IF 
    Serial.println("connected");
    // Make a HTTP request:
    String url = "http://192.168.1.58:80/gprs_rfid/rest/insertrfiddata";
    Serial.print("Requesting URL: ");
    Serial.println(url);

    client.print("POST " + url + " HTTP/1.1\r\n" +
                 "Host: " + host + "\r\n" + 
                 "Content-Type: application/json\r\n" +
                 "Connection: close\r\n\r\n");
//    Serial.println(data);
////    client.print("GET http://192.168.1.58:80/gprs_rfid/rest/readrfiddata?"); //dont make these println
//    client.print("POST http://192.168.1.58:80/gprs_rfid/rest/insertrfiddata"); //dont make these println
//    client.println(" HTTP/1.1");
//    client.print("Host: 192.168.1.58");
//    client.print("Content-Type: application/json");
//    client.print(data);   //dont make these println
////    client.println(server);
//    client.println("Connection: close");
//    client.println();
    Serial.print("SENT");
    Serial.println();
    first++;
    Serial.print(first);
    Serial.println();
    Serial.println(data); 

    // add this
    while(client.connected()) {
        while(client.available()) {
            String inChar = client.readStringUntil('\r');
            Serial.print(inChar);
        }
    }
// end of add

    client.stop();
    
  } //end OF IF

}
}
//}

and the error is

Scan a MIFARE Classic PICC to demonstrate Value Blocks.
My IP address: 192.168.1.201.connecting...
 ae d8 04 3bresult=ae d8 4 03b 
1
connected
Requesting URL: http://192.168.1.58:80/gprs_rfid/rest/insertrfiddata
SENT
1
tag=ae d8 4 03b 
HTTP/1.1 200 OK
Date: Wed, 15 Mar 2017 09:22:46 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28
X-Powered-By: PHP/5.6.28
Content-Length: 173
Connection: close
Content-Type: application/json



<b>Notice</b>:  Undefined index: tag in <b>C:\xampp\htdocs\gprs_rfid\rest\api.php</b> on line <b>90</b>

{"status":"Success","msg":"data inserted Successfully."}

thanks in advanced…

Couple of errors.

// this uses DNS. Replace with IPAddress host(192,168,1,58);
const char* host="192.168.1.58";  // numeric IP for server (no DNS) (reduce sketch size)

// this has the protocol prepended. Drop the http:// part.
String url = "http://192.168.1.58:80/gprs_rfid/rest/insertrfiddata";

Thank you so much.As u said, sir i have done that but i got an error in serial monitor

Scan a MIFARE Classic PICC to demonstrate Value Blocks.
My IP address: 192.168.1.201.connecting...
tag=ae d8 4 03b 
1
connected
tag=ae d8 4 03b 
SENT
1
tag=ae d8 4 03b 
HTTP/1.1 400 Bad Request
Date: Wed, 15 Mar 2017 19:11:53 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28
Vary: accept-language,accept-charset
Accept-Ranges: bytes
Connection: close
Content-Type: text/html; charset=utf-8
Content-Language: en
Expires: Wed, 15 Mar 2017 19:11:53 GMT

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Bad request!</title>
<link rev="made" href="mailto:postmaster@localhost" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/ 
    body { color: #000000; background-color: #FFFFFF; }
    a:link { color: #0000CC; }
    p, address {margin-left: 3em;}
    span {font-size: smaller;}
/*]]>*/--></style>
</head>

<body>
<h1>Bad request!</h1>
<p>


    Your browser (or proxy) sent a request that
    this server could not understand.

</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:postmaster@localhost">webmaster</a>.

</p>

<h2>Error 400</h2>
<address>
  <a href="/">localhost</a>

  <span>Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28</span>
</address>
</body>
</html>

please please help me out of this.

You don’t need the port or server IP either.

String url = "/gprs_rfid/rest/insertrfiddata";

Thank u.I have tried that but I am getting the same problem in serial monitor…i don’t know where the problem is…once I know where the problem is…then I get to answer…please help me out of this…I am struggling so many days…and I get disappointed

Scan a MIFARE Classic PICC to demonstrate Value Blocks.
My IP address: 192.168.1.201.connecting...
tag=ae d8 4 03b 
1
connected
Requesting URL: /gprs_rfid/rest/insertrfiddata
SENT
1

HTTP/1.1 200 OK
Date: Thu, 16 Mar 2017 02:23:31 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28
X-Powered-By: PHP/5.6.28
Content-Length: 173
Connection: close
Content-Type: application/json



<b>Notice</b>:  Undefined index: tag in <b>C:\xampp\htdocs\gprs_rfid\rest\api.php</b> on line <b>90</b>

{"status":"Success","msg":"data inserted Successfully."}

please help me...I need your help...

In this project, I have used two SPI interface, one in ethernet shield and one in HF RFID...so it collapses in both SPI interface (at a time only one is working) and my ethernet shield is using 10,11,12,13 pins in Arduino Uno and at the same time HF RFID using same pins as SPI interface.when I am posting RFID data to a server it's giving me an empty column in the MySQL database and in Arduino it's giving as an undefined index: tag.Where I am getting problem....I don't know ....exactly please help me out with this...