How to gather user input with a HTML email subscription form and store that data in a MySQL Database using PHP



Share this page:



  

<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.

How to gather user input with a HTML email subscription form and store that data in a MySQL Database using PHP


Page Sections:

  1. What are the 'src' and 'public' files used for?
  2. Javscript example
  3. SCSS example

Share this page:



  

<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.