Learn one of the most powerful programming languages in the world and become a rockstar developer.

PHP Form Introduction

What Are Forms?

In HTML, we can create forms with inputs like text fieldstext areascheckboxesradio buttons, etc. to get some data from the user. Then, we can submit the user input to the server and process them.

In web development, handling a HTML form is perhaps the most important process. Two steps are involved:

  • Creating the HTML form
  • Creating the corresponding PHP script that will receive and process the form data

Where Are Forms Used?

Almost every website has forms. Including,

  • Comment forms
  • Subscribe forms
  • Contact us forms
  • Search Forms

Forms are really handy when creating dynamic websites.



        <title>PHP Information Registration</title>


            $name = $email = $gender = $comment = $website = "";
            if ($_SERVER["REQUEST_METHOD"] == "POST") {
                $name = test_input($_POST["name"]);
                $email = test_input($_POST["email"]);
                $website = test_input($_POST["website"]);
                $address = test_input($_POST["address"]);
                $gender = test_input($_POST["gender"]);

            function test_input($data) {
                $data = trim($data);
                $data = stripslashes($data);
                $data = htmlspecialchars($data);
                return $data;

    <h2>Adzetech Information registration</h2>

    <form method = "post" action = "">
                    <td><input type = "text" name = "name"></td>

                    <td><input type = "text" name = "email"></td>

                    <td><input type = "text" name = "address"></td>

                    <td><input type="url" name = "website" ></td>

                          <input type = "radio" name = "gender" value = "female">Female
                          <input type = "radio" name = "gender" value = "male">Male

                        <input type = "submit" name = "submit" value = "Submit">

          echo "<h2>Your Given details are as :</h2>";
          echo $name;
          echo "<br>";

          echo $email;
          echo "<br>";

          echo $website;
          echo "<br>";

          echo $address;
          echo "<br>";

          echo $gender;



php form introduction demo

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Privacy Policy That's Fine