0

This is in my .erb file:

<form  method="post" action="/login" id="login" enctype="text/plain"> 
Username: <input type="text" id="username" placeholder="Enter username here">
Password: <input type="password" id="password" placeholder="Enter password here">
<%= @error (will display if wrong) %>
<input TYPE="button" VALUE="Submit" />
</form>

And this is in my .rb file:

post '/login' do
  #connects to database
  if #connection successful
    # does something
  else
    #do something else
  end
end

However, when I try to click my "Submit" button to log in, nothing happens. Originally I was connecting to a database and checking for info, but after that I was just trying to set an error message to be a certain value, and even that won't work. I know this is something silly I'm missing. What piece is not there? (Using Postgres with Eruby, and it's running on Heroku.)

matt
  • 78,533
  • 8
  • 163
  • 197

1 Answers1

0

You’re using the button type of input, for which the docs say:

The input element represents a button with no default behavior.

This type of input control is usually used when you want to attach some javascript behaviour to a button. For submitting a form, you want type=submit:

The input element represents a button that, when activated, submits the form.

So in your Erb file, change this line:

<input TYPE="button" VALUE="Submit" />

to

<input TYPE="submit" VALUE="Submit" />
matt
  • 78,533
  • 8
  • 163
  • 197