A simple newsletter sign-up form
Time to get our hands dirty. Let's start off small with a newsletter sign-up form. With just a single input text field for an email address, and a submit
button, this is going to be one of the simplest forms you can build! We'll eventually add this form to the sidebar of the product page we developed in the previous chapter.
Note
The starting point for the examples in this chapter is /ch6/form-start.html
. You can follow along with the examples by building on the code in this file.
First, let's set this up as a GET form, and afterwards, we'll change it to a POST submission to see what we need to do differently (/ch6/signup.html
):
<form method="get" action="/ch6/signup.php" target="_top"> <input type="email" name="email" id="email" required> <input type="submit" value="Sign me up!"> </form>
Note
We're using a PHP server to handle the form submission here due to its wide availability and ease of use. You can use any server technology you...