summaryrefslogtreecommitdiffstats
path: root/src/civetweb/test/form.html
blob: 381084ce18871a8b7dbb538a5e8b3183a1b77d75 (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE HTML>
<html>

<head>
  <meta charset="UTF-8">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Example page for HTML form handling</title>
</head>

<body>

  <!-- HTML forms can use GET or POST, and the encoding can be application/x-www-form-urlencoded or multipart/form-data.
       If no method is specified (like <form method="method">), GET should be the default method.
       If no encoding is specified, application/x-www-form-urlencoded should be the default.
       Submit buttons may overwrite action, method and enctype by using formaction, formmethod and formenctype.

       References:
       http://www.w3.org/TR/html401/interact/forms.html
       http://www.w3schools.com/html/html_forms.asp,
       http://www.w3schools.com/html/html_form_attributes.asp
       http://www.w3.org/TR/html401/interact/forms.html#adef-enctype
  -->


  <form action="/handle_form.embedded_c.example.callback">
    See <a href="http://www.w3schools.com/html/html_form_input_types.asp">HTML form tutorial</a>
    and <a href="http://www.w3.org/TR/html401/interact/forms.html">HTML spec</a>.<br />

    <fieldset>
      <legend>Text inputs:</legend>
      A text: <input type="text" name="textin"><br />
      A password: <input type="password" name="passwordin"><br />
    </fieldset>

    <fieldset>
      <legend>Radio set 1:</legend>
      <input type="radio" name="radio1" value="val1" checked>val1<br />
      <input type="radio" name="radio1" value="val2">val2<br />
      <input type="radio" name="radio1" value="val3">val3<br />
    </fieldset>

    <fieldset>
      <legend>Radio set 2:</legend>
      <input type="radio" name="radio2" value="val1" checked>val1<br />
      <input type="radio" name="radio2" value="val2">val2<br />
      <input type="radio" name="radio2" value="val3">val3<br />
    </fieldset>

    <fieldset>
      <legend>Checkboxes:</legend>
      <input type="checkbox" name="check1" value="val1" checked>val1<br />
      <input type="checkbox" name="check2" value="val2">val2<br />
      <input type="checkbox" name="check3" value="val3">val3<br />
    </fieldset>

    <fieldset>
      <legend>HTML5 inputs:</legend>
      A number: <input type="number" name="numberin" min="1" max="5"><br />
      A date: <input type="date" name="datein"><br />
      A color: <input type="color" name="colorin"><br />
      A range: <input type="range" name="rangein" min="1" max="5"><br />
      A month: <input type="month" name="monthin"><br />
      A week: <input type="week" name="weekin"><br />
      A time: <input type="time" name="timein"><br />
      A datetime: <input type="datetime" name="datetimen"><br />
      A datetime-local: <input type="datetime-local" name="datetimelocalin"><br />
      An email: <input type="email" name="emailin"><br />
      A search: <input type="search" name="searchin"><br />
      A tel: <input type="tel" name="telin"><br />
      An url: <input type="url" name="urlin"><br />
    </fieldset>

    <fieldset>
      <legend>Files:</legend>
      A file: <input type="file" name="filein"><br />
      Multiple files: <input type="file" name="filesin" multiple><br>
    </fieldset>

    <fieldset>
      <legend>Dropdown:</legend>
      <select name="selectin">
        <option value="opt1">opt1</option>
        <option value="opt2">opt2</option>
        <option value="opt3">opt3</option>
      </select>
    </fieldset>

    <fieldset>
      <legend>Text area:</legend>
      <textarea name="message" rows="10" cols="30">Text area default text.</textarea>
    </fieldset>

    <fieldset>
    <legend>Submit:</legend>
      <fieldset>
        <legend>Submit to Lua script:</legend>
        This will only work if server side Lua scripting is activated and /handle_form.lua can be found on the server.
        <br>
        <input type="submit" value="Submit"  formmethod="POST"  formenctype="multipart/form-data"
         formaction="/handle_form.lua">
      </fieldset>

      <fieldset>
        <legend>Submit to callback:</legend>
        This will work in the embedded_c example. It will call mg_handle_form_data to parse the request.
        <br>
        <input type="submit" value="Submit (form default)">
        <input type="submit" value="Submit (GET)"                 formmethod="GET">
        <input type="submit" value="Submit (POST)"                formmethod="POST">
        <input type="submit" value="Submit (POST, url-encoded)"   formmethod="POST"   formenctype="application/x-www-form-urlencoded">
        <input type="submit" value="Submit (POST, form-data)"     formmethod="POST"   formenctype="multipart/form-data">
      </fieldset>
    </fieldset>

  </form>
</body>

</html>