1. Knowledge Base
  2. >
  3. Results
  4. >
  5. Article

PHP Contact form

A contact form is an effective tool for communicating with visitors on your website. It allows visitors to leave messages and post inquiries about your products and services or comment on your content. Typically, a contact form has the name, email, subject, and message input field. This article features code for a PHP contact form script. It is responsive and will work seamlessly on mobile, tablet, and other devices.

Below is an HTML code to create your contact form:

<form action="contact.php" method="post">
  <div class="elem-group">
    <label for="name">Your Name</label>
    <input type="text" id="name" name="visitor_name" placeholder="John Doe" pattern=[A-Zsa-z]{3,20} required>
  </div>
  <div class="elem-group">
    <label for="email">Your E-mail</label>
    <input type="email" id="email" name="visitor_email" placeholder="john.doe@email.com" required>
  </div>
  <div class="elem-group">
    <label for="department-selection">Choose Concerned Department</label>
    <select id="department-selection" name="concerned_department" required>
        <option value="">Select a Department</option>
        <option value="billing">Billing</option>
        <option value="marketing">Marketing</option>
        <option value="technical support">Technical Support</option>
    </select>
  </div>
  <div class="elem-group">
    <label for="title">Reason For Contacting Us</label>
    <input type="text" id="title" name="email_title" required placeholder="Unable to Reset my Password" pattern=[A-Za-z0-9s]{8,60}>
  </div>
  <div class="elem-group">
    <label for="message">Write your message</label>
    <textarea id="message" name="visitor_message" placeholder="Say whatever you want." required></textarea>
  </div>
  <button type="submit">Send Message</button>
</form>

Thanks for visiting! Since you landed on this page of our website, we wanted to let you know you visited one of our paid endorsers while researching your purchase. close

Chat
Close