Passing rfid uid to textfield php via network.

Hi arduino'ers, Master Arduino...

Could you please help me , i'm very new in arduino, i'm facing problem to passing the rfid uid to textfield in php via network,i'm using uno,mfrc522 and Ethernet shield W5100, for now I able to send and save rfid uid to MySQL database, but in another reason I want to send rfid uid to text field in php before I save to the MySQL database. my code is :

Arduino code:

#include <SPI.h>
#include <MFRC522.h>
#include <Ethernet.h>

#define SS_PIN 7
#define RST_PIN 6
MFRC522 mfrc522(SS_PIN, RST_PIN);        // Create MFRC522 instance.

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

IPAddress server(192,168,1,201);  // 
IPAddress ip(192,168,1,202);      //

EthernetServer svr(80);
EthernetClient client; //
String readString;

int first=0;
int counter=0;
String uID;


void setup() {
        svr.begin(); //
        Serial.begin(9600);        // 
        Serial.println("Server/Client test");
        Serial.println("Sending data RFID Test");
        
        // disable SD SPI
        pinMode(4, OUTPUT);
        digitalWrite(4, HIGH);
        
        // disable w5100 SPI
        pinMode(10, OUTPUT);
        digitalWrite(10, HIGH);
        
        SPI.begin();                // 
        mfrc522.PCD_Init();        // 
        
        
        Ethernet.begin(mac, ip); //
    
        // Local IP address:
        Serial.print("My IP address: ");
        for (byte thisByte = 0; thisByte < 4; thisByte++) {
        // cetak IP address:
        Serial.print(Ethernet.localIP()[thisByte], DEC);
        Serial.print(".");
        }
        //
        delay(1000);
        Serial.println("connecting...");
}

void loop() {
  
          // 
        MFRC522::MIFARE_Key key;
        for (byte i = 0; i < 6; i++) {
                key.keyByte[i] = 0xFF;
        }
        // Look for new cards
        if ( ! mfrc522.PICC_IsNewCardPresent()) {
                return;
        }

        // Select one of the cards
        if ( ! mfrc522.PICC_ReadCardSerial()) {
                return;
        }
               
              
                
    int val1=(mfrc522.uid.uidByte[0]);
    int val2=(mfrc522.uid.uidByte[1]);
    int val3=(mfrc522.uid.uidByte[2]);
    int val4=(mfrc522.uid.uidByte[3]);
    
    String valA=String(val1);
    String valB=String(val2);
    String valC=String(val3);
    String valD=String(val4);
    uID=valA+valB+valC+valD;
    Serial.print(uID);
    Serial.println();
    counter=counter+1;    
   Serial.print(counter); 
           
         
      
          
        //} 
        Serial.println();

   
        // Halt PICC
        mfrc522.PICC_HaltA();

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

   //Start as Server Now
   EthernetClient client= svr.available();
   if(client){
    while (client.connected()){
      if (client.available()){
        char c = client.read();
        
      }
    }
   }
       
    if (client.connect(server, 80)) { //start of IF
    Serial.println("connected");
    // Make a HTTP request:
    client.print("GET /sys/new.php?scnId="); //dont make these println
    client.print(uID);   //dont make these println
    client.println("HTTP/1.1");
    client.println("Host: 192.168.1.201");
    client.println("User-Agent: Arduino");
    client.println("Accept: text/html");
    client.println(server);
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println("Connection: close");
    client.println();
    Serial.print("SENT");
    Serial.println();
    first++;
    Serial.print(first);
    Serial.println();

    while(client.connected()){
      while(client.available()){
        char c = client.read();
        Serial.write(c);
      }
    }
    client.stop(); 
    
  } //end OF IF
  
        
    }//delay ifs   

}

what should I add into the Arduino code , so that to be display on textfield in PHP. please help me,Thank you.

maybe something like:

. . . 
client.print("GET /sys/new.php?scnId="); //dont make these println
client.print(uID);   //dont make these println
client.print("&myNewField=") ;  //you define this on your php/html page
client.print(123) ;  //or say client.print(myVal);
client.println("HTTP/1.1");
. . .

Hi 6v6gt ,

Thank you , your quick reply, i'll try later, once I reach of my uno. thank you so much.

6v6gt:
maybe something like:

. . . 

client.print("GET /sys/new.php?scnId="); //dont make these println
client.print(uID);   //dont make these println
client.print("&myNewField=") ;  //you define this on your php/html page
client.print(123) ;  //or say client.print(myVal);
client.println("HTTP/1.1");
. . .

Hi 6v6gt,

i have been followed, i got rfid value in php, when i read in serial Monitor, but that's not showing in text field. so when i save the data by clicking submit button, rfid tag it still empty. do you have any example of the php script or javascript to view the rfid value on textfield in php.

below is capture of the data that i got from Serial Monitor

<div class="row">
 <div class="col-md-12">
 <div class="col-md-6">
 <div class="well well-sm">
 <div class="form-group">
  <label for="scnId">RFID Data:</label>
  <input type="text" class="form-control" id="scnId" name="scnId"
  14472145124 
 >
  
 </div>
 <button class="btn btn-success " type="submit" id="buttonSave" name="buttonSave">
   Save Data
    </button>
   </form>
 </div>
 </div>
 <div class="col-md-6"></div>
 </div>
 </div>
 </div>


 </div>
 </div>

 <script src="bootstrap/js/jquery-1.11.1.min.js"></script>
 <script src="bootstrap/js/bootstrap.js"></script>

 <script type="text/javascript">

and these is PHP Code :

<div class="row">
 <div class="col-md-12">
 <div class="col-md-6">
 <div class="well well-sm">
 <div class="form-group">
  <label for="scnId">RFID Data:</label>
  <input type="text" class="form-control" id="scnId" name="scnId"
  <?php 
 //echo 'autofocus';
   if(isset($_GET['newVal'])){
   echo $_GET['scnId'];
   
   }
   
   unset($errorID);
   ?>
 
 >
  
 </div>
 <button class="btn btn-success " type="submit" id="buttonSave" name="buttonSave">
   Save Data
    </button>

OK. I think I misunderstood your first post in that I thought you wanted to send an additional data item to the database.

It now looks like you want to load the field "scnId" with a value and make this value visible somewhere. You have said that you have already solved the problem of getting the value of "scnId" into the database.

What I don't understand is how you expect to see the page "scnId" it is on. That page is submitted by the Arduino directly via a GET statement to the Web/PHP server for entry into the database and you won't have a chance to see it.

Or do you want to design a form with a field "scnId" which you can (also) use manually from a web browser to submit a value to the database ?

It would also be possible to design a form which retrieved a value of "scnId" from the database to display it, and even edit it and send it back if that is what you want.