[PHP] GET. POST 샘플

Web/php 2018. 4. 4. 22:32

* GET 방식 : URL에 값 표시 함



- get_test.html

--------------------------------------------------------------------------------------------

<!DOCTYPE html>

<html>

<head>

  <meta charset="utf-8">

</head>

<body>

  <form action="get_test.php" method="get">

    get 테스트값 : <input type="text" name="get_test"><br>

    <input type="submit" value="확인">

  </form>

</body>

</html>

--------------------------------------------------------------------------------------------



- get_test.php

--------------------------------------------------------------------------------------------

<?php

  $getTestValue = $_GET[get_test];


  echo "전달 받은 get 값은 {$getTestValue}입니다.";

?>

--------------------------------------------------------------------------------------------




======================================================




* POST 방식 : URL에 값 표시하지 않음


- post_test.html

--------------------------------------------------------------------------------------------

<!DOCTYPE html>

<html>

<head>

  <meta charset="utf-8">

</head>

<body>

  <form action="post_test.php" method="post">

    post 테스트값 : <input type="text" name="post_test"><br>

    <input type="submit" value="확인">

  </form>

</body>

</html>

--------------------------------------------------------------------------------------------



- post_test.php

--------------------------------------------------------------------------------------------

<?php

  $postTestValue = $_POST[post_test];


  echo "전달 받은 post 값은 {$postTestValue}입니다.";

?>

--------------------------------------------------------------------------------------------

'Web > php' 카테고리의 다른 글

[PHP] 배열  (0) 2018.04.05
[PHP] 기본 형태  (0) 2018.04.02
Posted by 깡's
,