php form of insert form on a Web page

Insert in the form of ordinary WEB page is as follows: This will create a more complete form, the <form> elements and attributes of all basic all displayed.

 

First, the HTML <body> </ body> tag add a <form> form. FIG processing member to the marble

Then <form> added in the form of a series of form elements and attributes. Here in the form of tags to add some CSS styles, so let friends look on page sensory few more cool.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <title>Document</title>

</head>

<body>

<form action="index.php" method="post" name="form1" enctype="multipart/form-data">

  <table width="400" border="1" cellpadding="1"  bgcolor="#999999">

    <tr bgcolor="#FFCC33">

      <td width="103" height="25" align="right">姓名:</td>

      <td height="25">

        <input name="user" type="text" id="user" size="20" maxlength="100">

      </td>

    </tr>

    <tr bgcolor="#FFCC33">

      <td height="25" align="right">性别:</td>

      <td height="25" colspan="2" align="left">

        <input name="sex" type="radio" value="男" checked>男

            <input name="sex" type="radio" value="女" >女

         </td>

    </tr>

    <tr bgcolor="#FFCC33">

      <td width="103" height="25" align="right">密码:</td>

      <td width="289" height="25" colspan="2" align="left">

        <input name="pwd" type="password" id="pwd" size="20" maxlength="100">

      </td>

    </tr>

    <tr bgcolor="#FFCC33">

      <td height="25" align="right">学历:</td>

      <td height="25" colspan="2" align="left">

        <select name="select">

          <option value="专科">专科</option>

          <option value="本科" selected>本科</option>

          <option value="高中">高中</option>

        </select>

      </td>

    </tr>

    <tr bgcolor="#FFCC33">

      <td height="25" align="right">爱好:</td>

      <td height="25" colspan="2" align="left">

        <input name="fond[]" type="checkbox" id="fond[]" value="音乐">音乐

            <input name="fond[]" type="checkbox" id="fond[]" value="体育">体育

            <input name="fond[]" type="checkbox" id="fond[]" value="美术">美术

         </td>

    </tr>

    <tr bgcolor="#FFCC33">

      <td height="25" align="right">照片上传:</td>

      <td height="25" colspan="2">

        <input name="image" type="file" id="image" size="20" maxlength="100">

      </td>

    </tr>

    <tr bgcolor="#FFCC33">

      <td height="25" align="right">个人简介:</td>

      <td height="25" colspan="2">

        <textarea name="intro" cols="30" rows="10" id="intro"></textarea>

      </td>

    </tr>

    <tr align="center" bgcolor="#FFCC33">

      <td height="25" colspan="3">

        <input type="submit" name="submit" value="提交">

        <input type="reset" name="reset" value="重置">

      </td>

    </tr>

  </table>

</form>

</body>

</html>

Description: The form includes a form element commonly used: single-line text boxes, multi-line text boxes, single option (Radio), multiple choice (CheckBox), and a multiple choice menu.

maxlength with the name, the password text boxes associated attributes, which limits the user to enter a password maximum length of 100 characters.

The list box is a list of the menu, with its own values ​​for selected attributes under its name. selected is a specific property selected element, if there is an additional option to the property, put the item in the display as the first item is displayed.

SUMMARY intro text box, the text display according to rows and cols, row and column width.

checked the label refers to the value of a single option and multi-options, the default has been selected.

Save the file as index.php page.

上面文件中的form表单使用的是POST方法传递数据,所以用户提交的数据会保存到$_POST或$_REQUEST的超级全局数组中,我们根据$_POST数组中的值就可以处理提交的数据。在后面我们会详细介绍获取表单数据的方法,POST方法是其中之一,在method="post"中选择。获取表单数据时表单是应用中最基本的操作,所以请朋友们关注表单后面的课程介绍。

注意:由于该页未使用PHP脚本,因此该Web页属于静态页,可以将其保存为 .html格式,然后直接使用浏览器打开该文件查看运行结果即可。

Guess you like

Origin www.cnblogs.com/furuihua/p/12133944.html