课程进度 52% · 第12/22章第12/22章 · 标签 1/2
— 1 —
表单基础
php
1
<!-- HTML表单 -->
2
<form method="POST" action="submit.php">
3
<input type="text" name="username" required />
4
<input type="email" name="email" required />
5
<input type="password" name="pwd" minlength="6" />
6
<select name="city">
7
<option value="beijing">北京</option>
8
<option value="shanghai">上海</option>
9
</select>
10
<input type="checkbox" name="agree" /> 同意协议
11
<button type="submit">注册</button>
12
</form>
— 2 —
GET与POST
php
1
2
$search = $_GET['q'] ?? '';
3
$name = $_POST['username'] ?? '';
4
$email = $_POST['email'] ?? '';
5
$val = $_REQUEST['key'] ?? '';
6
if ($_SERVER['REQUEST_METHOD'] === 'POST') { }
7
form$_GET$_POSTmethodaction