On 15.08.2006 13:44, fabsy wrote:
> Im a newbie to ruby (hehe).
> I have a question.
> Is there any better way to do this? :
> 
> ---------------
> puts "Enter Username"
> usr = gets
> puts "Enter Password"
> usr_pass = gets
> User = "user"
> Pass = "pass"
> 
> if usr > User
> 	if usr_pass > Pass
> 	puts "Correct user and pass"
> 	else
> 	puts "Correct user"
> 	puts "Wrong pass"
> 	end
> else
> 	if usr_pass > Pass
> 	puts "Correct pass"
> 	else
> 	puts "Wrong pass"
> 	end
> 	puts "Wrong user"
> end

puts "Enter Username"
usr = gets
puts "Enter Password"
usr_pass = gets

if usr > "user" && usr_pass > "pass"
   puts "Login ok"
else
   puts "Wrong credentials"
end

Note: typically you do not report whether the user name or the password 
was invalid to give attackers as few information as possible.

Btw, why do you compare with greater than and a string?

Kind regards

	robert