How to Create PHP validation Contact Form in Few Simple Step? - Chinaitechghana

China iTech Ghana
Sunday, May 9, 2021 | views Last Updated 2021-05-09T19:55:50Z

Are you want to Create a PHP Validation contact form? This form helps to send Your message, and email address to other Gmail account successfully. If you already familiar with HTML, CSS, and MYSQL then this PHP validation contact form you can easily create with some simple instruction.

There are many ways to create working contact using a different programming language such as Node JS, Python, C++, and others. You don't need to create a responsive contact page just your message should successfully send to your Email friend.

One important thing that your PHP contact form doesn't work in localhost, You must upload your PHP contact form to the online Server or using XAMPP help to create a local server on Your computer.

How to Download and Use XAMPP?

After sending Create Your Contact form, You must know how to use XAMPP local server. Here is some step about download and use of XAMPP in your PC.

  • Go to Google Chrome and Search for XAMPP install.
  • Choose to operate the system and install a new version of XAMPP.
  • Exact file after download and click next next next.
  • The open XAMPP control panel then start  apache and MySQL 
  • Finally, You Go to Google chrome and search for localhost/dashboard
  • Now, You can create a new database and table to upload your PHP code.

After Install and setup your  XAMPP c Panel, Here we provide Some steps to Create your PHP working contact form, and Any visitor comes to your website and you get your Name, Email, Massage successfully. Copy this HTML, PHP, and  CSS code and Upload your Localhost server.

Step 1. First, create an index.php document and paste This code.  This document design your layout and some PHP function

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="bootstrap.css">
    <title>Contact Us Form In Php</title>

    <div class="container">
        <div class="row">
            <div class="col-lg-6 m-auto">
                <div class="card mt-5">
                    <div class="card-title">
                        <h2 class="text-center py-2"> Contact Us </h2>
                            $Msg = "";
                            $Msg = " Please Fill in the Blanks ";
                                echo '<div class="alert alert-danger">'.$Msg.'</div>';
                         $Msg = " Your Message Has Been Sent ";
                            echo '<div class="alert alert-success">'.$Msg.'</div>';
                        <form action="process.php" method="post">
         <input type="text" name="UName" placeholder="User Name" class="form-control 
         <input type="email" name="Email" placeholder="Email" class="form-control 
        <input type="text" name="Subject" placeholder="Subject" class="form-control 
  <textarea name="msg" class="form-control mb-2" placeholder="Write The Message">
         <button class="btn btn-success" name="btn-send"> Send </button>

 Step: 2: After copy this index.php document you should create another mail.php file where this PHP help to send a message.


       $UserName = $_POST['UName'];
       $Email = $_POST['Email'];
       $Subject = $_POST['Subject'];
       $Msg = $_POST['msg'];

       if(empty($UserName) || empty($Email) || empty($Subject) || empty($Msg))
           $to = "";


 Once you completely create these two files index.php and mail.PHP file, now you can upload the file to the Localhost server or any other online server. This is the complete and best way to create any form easily. If anyone can send a message without fill information then it shows the error in filling in information. 

Enter Your Email Address to Recieve Our Latest Updates:

Delivered by

comments that appear entirely the responsibility of commentators as regulated by the ITE Law
  • How to Create PHP validation Contact Form in Few Simple Step? - Chinaitechghana

Trending Now