Noob Question

Posts 16 of 6 · Page 1 of 1
Noob Question
I need the username and password to individually loop back on incorrect input. (P.S I started coding C# today and this is all free typed code from my brain and I am very proud so far. Can't seem to figure out the loop part though? Maybe 'While' command?)

Code:
        static void Main(string[] args)
        {
            //This is the login terminal
            string userName, passWord;

            //Message header
            Console.WriteLine("Warning!");
            Console.WriteLine("Using a single license on more than a single device will result in a HWID & IP Ban!");

            //Username settings
            Console.Write("Please Enter Username: ");
            userName = Convert.ToString(Console.ReadLine());
            if (userName == "Hayden")
                while (userName != "Hayden")
                    {
                        Console.WriteLine("Thank you Hayden");
                    }
            else
                    {
                        Console.WriteLine("I'm sowwy but that's incorrect :(");
                    }
            //Password settings
                Console.Write("Please Enter Password: ");
            passWord = Convert.ToString(Console.ReadLine());
            if (passWord == "Password")
            {
                Console.WriteLine("Thank you Senpai");
            }
            else
            {
                Console.WriteLine("IP Log Initiated. Incorrect Login.");
            }
            Console.Read();
(As you can see I attempted the 'While' command. You may disregard that or remove it if incorrect .

Thank you
I'm adding an IP logger. If I want to display the external IP and the string name for it is externalIp then how do I put it after say Console.WriteLine("Your EIP - ");
????????

- - - Updated - - -

I'm getting an error (The name 'externalIp' does not exist in the current context). See section of code

//Password settings

string str = "Your EIP is - " + externalIp + ".";
Console.Write("Please Enter Password: ");
passWord = Convert.ToString(Console.ReadLine());
if (passWord == "Password")
{
Console.WriteLine("Thank you Senpai");
}
else
{
Console.WriteLine("IP Log Initiated. Incorrect Login.");
Console.WriteLine(str);

}
Console.Read();
Quote Originally Posted by Azronc View Post
I need the username and password to individually loop back on incorrect input. (P.S I started coding C# today and this is all free typed code from my brain and I am very proud so far. Can't seem to figure out the loop part though? Maybe 'While' command?)
Code:
        static void Main(string[] args)
        {
            string name, pw;

            name = Console.ReadLine();
            pw = Console.ReadLine();
            
            while(name != "test" || pw != "test")
            {
                Console.WriteLine("Wrong");
                name = Console.ReadLine();
                pw = Console.ReadLine();
            }
            Console.WriteLine("Correct");
            Console.ReadLine();
        }
What is wrong about this?

//Username Config

userName = Console.ReadLine();

while(userName != "Sir")
{
Console.WriteLine("Incorrect Login");
userName = Console.ReadLine();
}

Console.WriteLine("Welcome Sir");
Console.ReadLine();
Quote Originally Posted by Azronc View Post
What is wrong about this?
Nothing if you are only looking for the username.
I would help you but I dont understand what the fuck your doing Rotfl
Posts 16 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?