The code uploaded successfuly but it doesn't work

Not really.

This is not letting your program progress past the first line:

  if (rc522.PICC_IsNewCardPresent() && rc522.PICC_ReadCardSerial()) {

Your card reader is not working.