What I want to do is to be able to put an error message of my choosing if username/password combo is wrong I can just make another view but want to be able to just go back to login screen instead if having to go to a invalid login view I know there has to be something simple I can add on next line after :login but when i put "This is a sample error message" or something like that it just will display it and not bring me back to login screen.
post '/login' do
authenticate
if @auth == 1
erb :main
else
erb :login
end
end
Well I figured out my issue Im not redirecting anymore i added a parameter to my code
Post '/login' do authenticate if @auth == 1 erb :main else erb:login,:locals => {:message => "Failed"} end end and
get '/login' do erb :login ,:locals => {:message => "!!Type in your username and password!!"}
and in my view file
<form action="/login" method="POST">
<input class="login" type="text" name="username" value="Username"><br>
<input class="login" type="password" name="password" value="Password"><br>
<input class="submit" type="submit" value="Submit...If you dare">
<form action="/login" method="POST">
<%=message%>
</form>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.