MajesticForm Contact Form Pro Form Creator Guides Login HOW TO CREATE A SIMPLE HTML CONTACT FORM In this guide we'll show you how to create a simple HTML and PHP contact form to email using easy to understand code. One of the most useful pages of any website is the HTML contact form page. No website should be without a contact form. Scroll down a little to see our form created using HTML for the front-end. Further down you will see the PHP code for the form processing at the back-end - this is used to take the form submissions and send it to you by email. Index of this page: HTML Form Code CSS Styles Code Form PHP Processing Code Example HTML Form Form Tag HTML Text Field HTML Textarea Field HTML Radio Buttons HTML Checkboxes HTML File Upload HTML Password Field HTML Drop down menus HTML Submit Buttons HTML Reset Buttons The form shown below is a "bare-bone" version only, however, if you want to look at a fuller version, please download our free contact form We're here to help Already have a form and need some help? We offer installation, upgrades, fixes, and customisations. Get in touch to see how we can help. Form created using HTML Want to learn the fundamentals of contact forms and a short history of HTML forms? then read the definitive guide to contact forms. You can copy and paste this directly into your HTML page, or use it as a basis for your contact us page. contact form

Contact us

Simple HTML email form provided by MajesticForm
The CSS styles to use with the HTML form above File Name: contact-form.css (you must save using this name exactly) #fcf-form { display:block; } .fcf-body { margin: 0; font-family: -apple-system, Arial, sans-serif; font-size: 1rem; font-weight: 400; line-height: 1.5; color: #212529; text-align: left; background-color: #fff; padding: 30px; padding-bottom: 10px; border: 1px solid #ced4da; border-radius: 0.25rem; max-width: 100%; } .fcf-form-group { margin-bottom: 1rem; } .fcf-input-group { position: relative; display: -ms-flexbox; display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap; -ms-flex-align: stretch; align-items: stretch; width: 100%; } .fcf-form-control { display: block; width: 100%; height: calc(1.5em + 0.75rem + 2px); padding: 0.375rem 0.75rem; font-size: 1rem; font-weight: 400; line-height: 1.5; color: #495057; background-color: #fff; background-clip: padding-box; border: 1px solid #ced4da; outline: none; border-radius: 0.25rem; transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; } .fcf-form-control:focus { border: 1px solid #313131; } select.fcf-form-control[size], select.fcf-form-control[multiple] { height: auto; } textarea.fcf-form-control { font-family: -apple-system, Arial, sans-serif; height: auto; } label.fcf-label { display: inline-block; margin-bottom: 0.5rem; } .fcf-credit { padding-top: 10px; font-size: 0.9rem; color: #545b62; } .fcf-credit a { color: #545b62; text-decoration: underline; } .fcf-credit a:hover { color: #0056b3; text-decoration: underline; } .fcf-btn { display: inline-block; font-weight: 400; color: #212529; text-align: center; vertical-align: middle; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-color: transparent; border: 1px solid transparent; padding: 0.375rem 0.75rem; font-size: 1rem; line-height: 1.5; border-radius: 0.25rem; transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; } @media (prefers-reduced-motion: reduce) { .fcf-btn { transition: none; } } .fcf-btn:hover { color: #212529; text-decoration: none; } .fcf-btn:focus, .fcf-btn.focus { outline: 0; box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); } .fcf-btn-primary { color: #fff; background-color: #007bff; border-color: #007bff; } .fcf-btn-primary:hover { color: #fff; background-color: #0069d9; border-color: #0062cc; } .fcf-btn-primary:focus, .fcf-btn-primary.focus { color: #fff; background-color: #0069d9; border-color: #0062cc; box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5); } .fcf-btn-lg, .fcf-btn-group-lg>.fcf-btn { padding: 0.5rem 1rem; font-size: 1.25rem; line-height: 1.5; border-radius: 0.3rem; } .fcf-btn-block { display: block; width: 100%; } .fcf-btn-block+.fcf-btn-block { margin-top: 0.5rem; } input[type="submit"].fcf-btn-block, input[type="reset"].fcf-btn-block, input[type="button"].fcf-btn-block { width: 100%; } The PHP Code which captures and Emails your website form The PHP code below is very basic - it will capture the form fields specified in the HTML form above (Name, Email, and Message). The fields are then sent off to your email address in plain text. Note: You need to edit 2 parts of the script below. You need to set your email address (this will not be available for anyone to see, it is only used by the server to send your email). You can also specify an email subject line (or just leave the one which is there). File Name: contact-form-process.php (you must use this filename exactly) Save the files above. Once you edit the form to fit with your design, you are ready to try it out. How the HTML form will look Contact us Your name Your email address Your message This versions below contains many more advanced features. HTML form field examples To add new fields to your form, just copy and paste the field type you need from the examples below. We have included a breakdown of different HTML Form tags. Learn much more about HTML5 form fields on our new definitive guide. HTML Form Tags HTML website forms should be enclosed inside the FORM tags. There are various parameter options available, the most common ones are: action - this allows you to tell the form where to go once submitted (usually the filename of a script which will read and process the form data which has been submitted). name - it's usually a good idea to give your forms a name, this is used to uniquely identify your form on a given page. method - the value of this should be POST or GET. Forms should usually be set to use POST (as GET will attach the form data onto the page URL which is almost always a bad idea for security reasons). There are some other methods available, but we will not discuss these here.
Example form field:
HTML Text Field - Single Line This is without doubt the most common field you will find.
Enter your name:
Text field in action Enter your name: HTML Textarea (multiple lines text field ) The multi-line text field (commonly known as a textarea field) is more suitable to takes a larger block of text from your visitors. This is ideal for messages.
Message: