2015.08.26 09:34

HTTP Redirect 시에 POST 값 넘기기

307 temporary redirect, 308 permanant redirect

위의 두가지 헤더를 사용하면 받은 POST 값을 자동으로 redirect 되는 페이지로 넘겨줌.

출처 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=80109&page=1 PHP스쿨 송효진님


<?php

if(!isset($_POST['data'])) { ?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Redirect Test</title>
</head>
<body>
<form method="post" action="">
<input type="text" name="data" value="test data">
<input type="submit" value="submit">
</form>
<?php highlight_file(__FILE__); ?>
</body>
</html>
<?php
exit;
}

if(!isset(
$_GET['redirect'])) {
header('HTTP/1.1 307');
header('Location: /exams/redirecttest.php?redirect');
exit;
}

echo 
'<xmp>';
print_r($_POST);
print_r($_GET);
echo 
'</xmp>';
exit;


Trackback 0 Comment 0