Jacob Paris
← Back to all content

Submit a form with basic HTML

When a user submits a form, the browser will send a request to the current route. By default, this is a GET request. The request type can be set using either method="GET" or method="POST".

html
<form method="POST">
<label>
Username
<input type="text" name="username" />
</label>
<label>
Password
<input type="password" name="password" />
</label>
<button type="submit">Submit</button>
</form>

You can change the route for the submission with the action attribute. This is useful for submitting forms to other pages.

html
<form action="/"></form>
<form action="/app/products/new"></form>

This can be used to make a log out button

html
<form method="POST" action="/logout">
<button type="submit">Log out</button>
</form>

This form will submit a GET request to Google Search.

html
<form action="https://google.com/search">
<input
aria-label="search"
type="text"
name="q"
/>
<button type="submit">Search</button>
</form>
Professional headshot
Moulton
Moulton

Hey there! I'm a developer, designer, and digital nomad building cool things with Remix, and I'm also writing Moulton, the Remix Community Newsletter

About once per month, I send an email with:

  • New guides and tutorials
  • Upcoming talks, meetups, and events
  • Cool new libraries and packages
  • What's new in the latest versions of Remix

Stay up to date with everything in the Remix community by entering your email below.

Unsubscribe at any time.