PHP 表单介绍

PHP 表单介绍

动态网站

网站提供功能,可以用来存储、更新、检索和删除数据库中的数据。

什么是表单

一个包含空白字段的文档,用户可以填写数据或选择数据。通常情况下,数据将存储在数据库中。

示例

下面的示例展示了使用post方法的具有特定操作的表单。

<html>

   <head>
      <title>PHP Form Validation</title>
   </head>

   <body>
      <?php

         // define variables and set to empty values
         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"]);
            comment = test_input(_POST["comment"]);
            gender = test_input(_POST["gender"]);
         }

         function test_input(data) {data = trim(data);data = stripslashes(data);data = htmlspecialchars(data);
            returndata;
         }
      ?>

      <h2>Tutorials Point Absolute classes registration</h2>

      <form method = "post" action = "/php/php_form_introduction.htm">
         <table>
            <tr>
               <td>Name:</td> 
               <td><input type = "text" name = "name"></td>
            </tr>

            <tr>
               <td>E-mail:</td>
               <td><input type = "text" name = "email"></td>
            </tr>

            <tr>
               <td>Specific Time:</td>
               <td><input type = "text" name = "website"></td>
            </tr>

            <tr>
               <td>Class details:</td>
               <td><textarea name = "comment" rows = "5" cols = "40"></textarea></td>
            </tr>

            <tr>
               <td>Gender:</td>
               <td>
                  <input type = "radio" name = "gender" value = "female">Female
                  <input type = "radio" name = "gender" value = "male">Male
               </td>
            </tr>

            <tr>
               <td>
                  <input type = "submit" name = "submit" value = "Submit"> 
               </td>
            </tr>
         </table>
      </form>

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

         echoemail;
         echo "<br>";

         echo website;
         echo "<br>";

         echocomment;
         echo "<br>";

         echo $gender;
      ?>

   </body>
</html>

它将生成以下结果-

PHP 表单介绍

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程