2012년 5월 14일 월요일

PHP get / post 처리

[Request method 확인]
$_SERVER['REQUEST_METHOD'] 값이 'POST' 또는 'GET' 인지 확인

[매개 변수 확인]
Method type 이 get 인 경우 $_GET['value'] 에 method type 이 post 이면 $_POST['value'] 로 확인

예)
<?php
if ($_SERVER['REQUEST_METHOD']=='POST') {
    echo "POST<br />";
    echo $_POST['id'];
} else {
    echo "GET<br />";
    echo $_GET['id'];
}
?>
<form method="post">
<input type="text" name="id" value="" />
<input type="submit" value="send" />
</form>

댓글 없음:

댓글 쓰기