Rfid not accepting valid input help

Hello, I am doing a project that involves using the arduino uno and the ethernet shield 2 with the sunfounder rfid-rc522 reader for my project. This involves me scanning the card and it uploads to a google spreadsheet. I think it works but it simply does not scan my card as valid even though I typed it in. I basically got this project from this link

https://create.arduino.cc/projecthub/embedotronics-technologies/attendance-system-based-on-arduino-and-google-spreadsheet-105621?ref=search&ref_id=rfid&offset=54

I would ask the creator but he won't respond to me. The code is attached of his that I modified to meet my standards.

I also attached the screenshot of what happens when I scan the tags.

If you help me on this I appreciate you. :slight_smile:

Testbeta2.ino (3.3 KB)

Read How to use this forum, and post your sketch on the forum using code tags.

You will never recognize a tag or card- because that's the way the code is written.

Consider the logic of your nested if statements.
if card 1 matches, AND card 2 matches, AND card 3 matches, AND card 4 matches, then you have a match.

Try changing the second through the third if to elseif, then the logic reads card 1 OR card 2 OR card 3 OR card 4.

void loop(){
    int m=0;
    if(!rfid.PICC_IsNewCardPresent())
    return;
    if(!rfid.PICC_ReadCardSerial())
    return;
    for(i=0;i<4;i++)
    {
     id_temp[0][i]=rfid.uid.uidByte[i]; 
               delay(50);
    }
    
     for(i=0;i<No_Of_Card;i++)
    {
            if(id[i][0]==id_temp[0][0])
            {
              if(id[i][1]==id_temp[0][1])
              {
                if(id[i][2]==id_temp[0][2])
                {
                  if(id[i][3]==id_temp[0][3])
                  {
                    Serial.print("your card no :");
                    for(int s=0;s<4;s++)
                    {
                      Serial.print(rfid.uid.uidByte[s]);
                      Serial.print(" ");

I don't really know how to setup elseif (I am a student), but I don't know why there are ids 0-3 when it only has three card data slots, and Im only using 2 valid ones, the 3rd one was already there from the guys project.
This is the card code

byte id[No_Of_Card][4]={
  {204,389,56,51},             //RFID NO-1
  {3010,9,31,52},             //RFID NO-2
  {142,76,58,42}              //RFID NO-3
};
byte id_temp[3][3];
byte i;
int j=0;

I appreciate your help with me, as I don't know much about this code.

RTFM

I won't write the code for you, but I will answer specific questions. I already showed you where your problem is and how to fix it.

    for(i=0;i<No_Of_Card;i++)
    {
            if(id[i][0]==id_temp[0][0]) {
              Serial.print("your card no :");
                    for(int s=0;s<4;s++)
                    {
                      Serial.print(rfid.uid.uidByte[s]);
                      Serial.print(" ");
                     
                    }
                    Serial.println("\nValid Person");
                    Sending_To_spreadsheet();
                    j=0;
                              
                              rfid.PICC_HaltA(); rfid.PCD_StopCrypto1();   return; 
            }
            
              else if(id[i][1]==id_temp[0][1]) {
                 Serial.print("your card no :");
                    for(int s=0;s<4;s++)
                    {
                      Serial.print(rfid.uid.uidByte[s]);
                      Serial.print(" ");
                     
                    }
                    Serial.println("\nValid Person");
                    Sending_To_spreadsheet();
                    j=0;
                              
                              rfid.PICC_HaltA(); rfid.PCD_StopCrypto1();   return; 
              }
                else if(id[i][2]==id_temp[0][2]) {
                  Serial.print("your card no :");
                    for(int s=0;s<4;s++)
                    {
                      Serial.print(rfid.uid.uidByte[s]);
                      Serial.print(" ");
                     
                    }
                    Serial.println("\nValid Person");
                    Sending_To_spreadsheet();
                    j=0;
                              
                              rfid.PICC_HaltA(); rfid.PCD_StopCrypto1();   return; 
                }
                  else if(id[i][3]==id_temp[0][3])
                  {
                    Serial.print("your card no :");
                    for(int s=0;s<4;s++)
                    {
                      Serial.print(rfid.uid.uidByte[s]);
                      Serial.print(" ");
                     
                    }
                    Serial.println("\nValid Person");
                    Sending_To_spreadsheet();
                    j=0;
                              
                              rfid.PICC_HaltA(); rfid.PCD_StopCrypto1();   return; 
                  }
     else
     {j++;
      if(j==No_Of_Card)
      {
        Serial.println("Not a valid Person");
        Sending_To_spreadsheet();
        j=0;
      }
     }
    }

I changed them to elseif statements and it still is saying that it is not a valid person so I dont know what Im doing wrong