How to Gather User Input with an HTML Email Subscription Form and Store That Data in a MySQL Database Using PHP

On this page you’ll learn how to create an HTML email subscription form to collect user input and store that data in a MySQL database using PHP

in Node.JS, AWS






<article class="card card-outline mb-4"> <div class="card-body"> <h4 class="card-title">Sign up for our email subscription</h4> <form method="POST" action="action_page.php"> <div class="mb-3"> <label for="email">Email:</label> <input type="email" class="form-control" id="email" placeholder="Enter email" name="email" data-ddg-inputtype="identities.emailAddress" data-ddg-autofill="true" style="background-size: auto 24px !important; background-position: right center !important; background-repeat: no-repeat !important; background-origin: content-box !important; !important; transition: background !important;"> <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </div> </article>

Output:

Sign up for our email subscription

We'll never share your email with anyone else.

This is a very simple HTML form that gets the user to enter an email address and then it will 'POST' that data to the 'action_page.php' file so that we can use/manipulate the data that the user has provided how we want using PHP.