반응형
# select.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form method="post" action="process.php">
<select name="taskOption1">
<option value="first">First</option>
<option value="second">Second</option>
<option value="third">Third</option>
</select>
<select name="taskOption2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="submit" value="Submit the form"/>
</form>
</body>
</html>
# process.php
<?php
$option1 = isset($_POST['taskOption1']) ? $_POST['taskOption1'] : false;
$option2 = isset($_POST['taskOption2']) ? $_POST['taskOption2'] : false;
if ($option1 & $option2) {
echo htmlentities($_POST['taskOption1'], ENT_QUOTES, "UTF-8").'<br>';
echo htmlentities($_POST['taskOption2'], ENT_QUOTES, "UTF-8");
} else {
echo "task option is required";
exit;
}
?>
반응형
'php' 카테고리의 다른 글
전역변수 & 지역변수 (0) | 2021.07.13 |
---|---|
기본 문법 (0) | 2021.07.10 |
양식(form)으로 전송된 데이터 전달받기 - $_GET, $_POST (0) | 2021.07.09 |
외부 파일을 포함하는 함수 [include(), include_once(), require(), require_once()] (0) | 2021.07.08 |
__FILE__ 과 __DIR__ (0) | 2021.07.07 |