how to register more UID tag with names in attendance system?

#include <MFRC522.h> 
#include <SPI.h> 
#include <SD.h> 
#include <RTClib.h> 


#define CS_RFID 10
#define RST_RFID 9

#define CS_SD 4 
#define RELAY 3

File myFile;


MFRC522 rfid(CS_RFID, RST_RFID); 


RTC_DS1307 rtc;





const int redLED = 6;
const int greenLED = 5;


void setup() {
    digitalWrite(RELAY, HIGH);
 
  pinMode(redLED, OUTPUT);  
  pinMode(greenLED, OUTPUT);

   pinMode(RELAY, OUTPUT);

  Serial.begin(9600);
  while(!Serial); 
  

  SPI.begin(); 
 
  rfid.PCD_Init(); 


  Serial.print("SD card...");
  if(!SD.begin(CS_SD)) {
    Serial.println("failed!");
    return;
  }
  Serial.println("done.");


  if(!rtc.begin()) {
    Serial.println("No RTC");
    while(1);
  }
  else {
    
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  if(!rtc.isrunning()) {
    Serial.println("NO RTC");
  }
}

void loop() {

  if(rfid.PICC_IsNewCardPresent()) 
  {
    readRFID();
 
  }
  delay(40);
}

void readRFID() {
   
  rfid.PICC_ReadCardSerial();
  Serial.print("Tag UID: ");
  String content= "";
  for (byte i = 0; i < rfid.uid.size; i++) 
    {
     Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(rfid.uid.uidByte[i], HEX);
     content.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(rfid.uid.uidByte[i], HEX));
  }
  Serial.println();

  content.toUpperCase();
   boolean authorized = false;
  char *name = "";


     if (content.substring(1) == "11 76 04 A3")  
  {
   authorized = true;
   name = "Jim E. Espinola"; 
  }

     if (content.substring(1) == "12 5C 1B 1C")  
  {
   authorized = true;
   name = "MaryFrance Hubilla"; 
  }
  
     if (content.substring(1) == "12 10 EE 1C")  
  {
   authorized = true;
   name = "JA Estipona"; 
  }

     if (content.substring(1) == "92 8D C6 1C")  
  {
   authorized = true;
   name = "Rona Aguila"; 
  }
       if (content.substring(1) == "02 EE 64 1C")  
  {
   authorized = true;
   name = "Homer Ereño"; 
  }
       if (content.substring(1) == "A2 30 BD 1C")  
  {
   authorized = true;
   name = "Raffy Torrella"; 
  }



  if (authorized) {
   Serial.println(name);
    digitalWrite(greenLED, HIGH);
     digitalWrite(RELAY, LOW);
  delay(3000);        
   digitalWrite(greenLED, LOW);
          digitalWrite(RELAY, HIGH);
  delay(500);
  digitalWrite(CS_SD,LOW);
  myFile=SD.open("DATA.txt", FILE_WRITE);
  if (myFile) {
  
    myFile.print(name);
    myFile.print(" _ ");   
    String content= "";
    
   
    DateTime now = rtc.now();
    myFile.print(now.month(), DEC);
    myFile.print('/');
    myFile.print(now.day(), DEC);
    myFile.print('/');
    myFile.print(now.year(), DEC);
    myFile.print('-');
    myFile.print(now.hour(), DEC);
    myFile.print(':');
    myFile.println(now.minute(), DEC);
    
  
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print('/');
    Serial.print(now.year(), DEC);
    Serial.print('-');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.println(now.minute(), DEC);
  
    myFile.close();


  }

  
  digitalWrite(CS_SD,HIGH);
}}

my code can only register 6 UID with names

Well obviously if you want to add a few more, it's a simple matter of copy & pasting this section and adjusting the name and ID:

     if (content.substring(1) == "11 76 04 A3")  
  {
   authorized = true;
   name = "Jim E. Espinola"; 
  }

Better to put that data in arrays. Better still an array of struct. Better again to get rid of the Strings. Perhaps even better to populate your array(s) from a file on the SD card.

by duplicating the

     if (content.substring(1) == "11 76 04 A3")  
  {
   authorized = true;
   name = "Jim E. Espinola"; 
  }

...
the arduino can only store six of that because of limited storage...

please help me to make a better code for naming UID, that are not storage-consuming

thank you

How many do you want? Which Arduino are you using?

Another thing you could look at is the use of progmem to store your names & IDs.

some actually suggested this>>

boolean authorized = false;
  char *name = "";

  for (int i=0; i < TagCount; i++)
  {
     if (uidString == allowedTags[i])
     {
       authorized = true;
       name = tagName[i]; 
     }
  }

char* allowedTags[] = {
  "1234y688678",         // Tag 1
  "2900940E95",         // Tag 2
  "ABC123DE45",         // Tag 3
};

// List of names to associate with the matching tag IDs
char* tagName[] = {
  "john",      // Tag 1
  "Mark ",      // Tag 2
  "james",       // Tag 3
};

but i’m confused on how to apply it to my code

Here is how you would use an array of structures to list the authorized users. Looks like each user adds about 16 bytes and you have over 800 bytes free. You might be able to add 10 or 20 more users before running into memory problems. Beyond that, move the user list into a file on the SD card. Read one line at a time to see if the user is authorized.

Note: I don’t have the same RTC library as you so I had to comment out the RTC lines.

#include <MFRC522.h>
#include <SPI.h>
#include <SD.h>
#include <RTClib.h>

struct USER
{
  unsigned long ID;
  const char *name;
} Users[] =
{
  {0x117604A3UL, "Jim E. Espinola"},
  {0x125C1B1CUL, "MaryFrance Hubilla"},
  {0x1210EE1CUL, "JA Estipona"},
  {0x928DC61CUL, "Rona Aguila"},
  {0x02EE641CUL, "Homer Ereño"},
  {0xA230BD1CUL, "Raffy Torrella"}
};
const byte UserCount = sizeof Users / sizeof Users[0];

#define CS_RFID 10
#define RST_RFID 9

#define CS_SD 4
#define RELAY 3

File myFile;

MFRC522 rfid(CS_RFID, RST_RFID);

//RTC_DS1307 rtc;

const int redLED = 6;
const int greenLED = 5;

void setup()
{
  Serial.begin(115200);
  while (!Serial);

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

  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);

  SPI.begin();

  rfid.PCD_Init();

  Serial.print("SD card...");
  if (!SD.begin(CS_SD))
  {
    Serial.println("failed!");
    return;
  }
  Serial.println("done.");

  //  if (!rtc.begin())
  //  {
  //    Serial.println("No RTC");
  //    while (1);
  //  }
  //  else if (!rtc.isrunning())
  //  {
  //    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  //  }
}

void loop()
{
  if (rfid.PICC_IsNewCardPresent())
  {
    readRFID();
  }
}

void readRFID()
{
  rfid.PICC_ReadCardSerial();
  
  unsigned long UIDVal = rfid.uid.uidByte[0];
  UIDVal = (UIDVal << 8) | rfid.uid.uidByte[1];
  UIDVal = (UIDVal << 8) | rfid.uid.uidByte[2];
  UIDVal = (UIDVal << 8) | rfid.uid.uidByte[3];

  Serial.print("Tag UID: 0x");
  Serial.println(UIDVal, HEX);

  boolean authorized = false;
  const char *name = "";

  for (int i = 0; i < UserCount; i++)
  {
    if (UIDVal == Users[i].ID)
    {
      authorized = true;
      name = Users[i].name;
      break;  // No need to look a the rest
    }
  }

  if (authorized)
  {
    Serial.println(name);
    digitalWrite(greenLED, HIGH);
    digitalWrite(RELAY, LOW);
    delay(3000);
    digitalWrite(greenLED, LOW);
    digitalWrite(RELAY, HIGH);
    delay(500);
    
    digitalWrite(CS_SD, LOW);
    myFile = SD.open("DATA.txt", FILE_WRITE);
    if (myFile)
    {
      myFile.print(name);
      myFile.print(" _ ");

      //      DateTime now = rtc.now();
      //      myFile.print(now.month(), DEC);
      //      myFile.print('/');
      //      myFile.print(now.day(), DEC);
      //      myFile.print('/');
      //      myFile.print(now.year(), DEC);
      //      myFile.print('-');
      //      myFile.print(now.hour(), DEC);
      //      myFile.print(':');
      //      myFile.println(now.minute(), DEC);
      //
      //
      //      Serial.print(now.month(), DEC);
      //      Serial.print('/');
      //      Serial.print(now.day(), DEC);
      //      Serial.print('/');
      //      Serial.print(now.year(), DEC);
      //      Serial.print('-');
      //      Serial.print(now.hour(), DEC);
      //      Serial.print(':');
      //      Serial.println(now.minute(), DEC);

      myFile.close();
    }
    digitalWrite(CS_SD, HIGH);
  }
}