#Im Making A Java Program That Asks You For A Login

84 messages · Page 1 of 1 (latest)

muted flax
#

Im Making A Java Program That Asks You For A Username(every name you want) And Asks You For A Password which is (123) and it doesnt work i write a name and password like 1234 and still lets me inside the program i tried else/if/else if but still didnt find anything that worked

drifting shoalBOT
#

This post has been reserved for your question.

Hey @muted flax! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

muted flax
naive slate
drifting shoalBOT
#

Looks like you're having some trouble comparing strings, check out this stackoverflow question for help.

muted flax
naive slate
#

(Y)

#

👍

muted flax
#

so i will have to use some kind of this? right?

naive slate
#

right

#

you need to compare pass with passs (terrible names btw)

muted flax
#

yes i know im just testing xd

#

but after i do it what should i do next to make the program check this and then continue

muted flax
naive slate
#

you're using the strings "pass" and "passs"

#

you should use the variables pass and passs

#

if(pass.equals(passs))

muted flax
#

o

#

oh

#

didnt think of that thank you so much

naive slate
#

👍

#

close post when done

muted flax
#

alr

#

so i have one last thing

#

after everything i have this

#

which tells you to put a key '

#

everything works but when i go here

#

and add something

#

it gives me an error

naive slate
#

what error

muted flax
#

like i add a key right?

#

and then it stops

#

it doesnt run this line

naive slate
#

works okay for me...

#

if you don't put in a number it will not work

muted flax
#

oh shit you are right

naive slate
#

meow

muted flax
#

meoww

#

now it works i had it as an integer

#

so it was only taking numbers

naive slate
#

yeah

muted flax
#

now one last thing i wanna make it register keys like

#

why this error?

naive slate
#

cos variable is called key1 not key

muted flax
naive slate
#

you can't use variable before declaring it

muted flax
#

oh alright let me see

#

yes but still lets me use what ever i want

#

i want it to use only this

#

as a key

naive slate
#

show latest?

#

i assume you've moved declaration of key outside the if statement

muted flax
naive slate
#

you're comparing key1 with key1

#

move declaration of key outside if statementa nd compare key with key1

muted flax
#

yes i understand but i want it first to ask you for the name and password

#

and then after successful and welcome

#

say String key = JOptionPane.showInputDialog("Enter Your Key");

naive slate
#

right

#

at the moment that bit^ is inside the inner if statement, move it out

#
get username
get pass
if pass is right:
  say hi
  get key
  if key is right
    show username, password and key
#

at the moment you have "get key" inside "if key is right" which doesn't make sense

muted flax
#

shit

#

you right

#

thank you so much for helping me and making me understand

naive slate
#

no probs

muted flax
#

now if i want it to have a message that says like wrong key

#

how should i do it

#

i promise its my last thing and we done

naive slate
#

use an else

#

if key equals key1 do this
else do that

muted flax
#

damn

naive slate
#
get username
get pass
if pass is right:
  say hi
  get key
  if key is right
    show username, password and key
  else
    show bad message
muted flax
#

i thought this will not work but i tried it

#

thanks

#

so much

#

have a nice day!

naive slate
#

you too