Notice: Undefined offset: 1886682 in /var/www/html/qa-external/qa-external-users.php on line 744
I need to validate my login with registration but I can't, help me! - OnlineGDB Q&A
Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I need to validate my login with registration but I can't, help me!

+2 votes
asked Nov 7, 2020 by Lucas Diegoo (140 points)
using System;
using System.IO;

class ProgramaPrincipal
{
    static void Main()
  {
      Console.Clear();
      int op;
      string login = @"F:\validl\login.txt";
      string texto = "**Sistema de login**\n";
      string cadastro = @"F:\validc\cadastro.txt";
      string textoc = "*****Sistema de cadastro*****\n";
      Console.ForegroundColor = ConsoleColor.DarkRed;
      File.WriteAllText(login,texto);
      do
      {
          Console.WriteLine("\t\t**MENU**");
          Console.WriteLine("1.LOGIN");
          Console.WriteLine("2.CADASTRO");
          Console.WriteLine("3.SAIR");
          Console.WriteLine("Insira a opção");
          op = Convert.ToInt32(Console.ReadLine());
          switch (op)
          {
              case 1:
              {
                  Console.Write("Login: ");
                  string login1 = Console.ReadLine();
                  Console.Write("Senha: ");
                  string senha = Console.ReadLine();
                  string validl;
                  validl = login1+","+senha+"\n";
                  File.Exists(login);
                  File.AppendAllText(login,validl);
                  break;
              }
              case 2:
              {
                  Console.WriteLine("*****Bem-vindo ao sistema de cadastro!*****");
                  Console.WriteLine("Insira o login desejado: ");
                  string logc = Console.ReadLine();
                  Console.WriteLine("Insira sua senha: ");
                  string senc = Console.ReadLine();
                  string validc;
                  validc = logc+","+senc+"\n";
                  File.Exists(cadastro);
                  File.AppendAllText(cadastro,validc);
                  break;
              }
              case 3:
              {
                  Console.WriteLine("Saindo do sistema...");
                  break;
              }
          }
  }while(op!=3);
}
}

1 Answer

–1 vote
answered Nov 8, 2020 by (10,560 points)
Looking at the code ,i think when you login,ie execute "case 1:" part you should be searching in the file for presence of string with username+','+password netered by user.

"Case 2" part is populating the data for usernames & password ,so it needs to be consumed by case 1.

 

Also please next time mention the code language.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...