본문 바로가기
Engineering WIKI/PHP

[PHP] 자신에게 폼 제출

by wonos 2019. 8. 17.


<!DOCTYPE html>
<meta charset="utf-8" />
<?php
$action = '';
if(isset($_POST['action']))$action = $_POST['action'];
 
//폼이 입력되었을 때 처리부
if($action == 'form_submit') {
  echo '<xmp>';
  print_r($_POST);
  echo '</xmp>';
 
  exit;
}
?>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
  <input type="hidden" name="action" value="form_submit" />
  <textarea name="textarea1"></textarea>
  <input type="submit" value="제출하기" />
</form>
  • action 값 $_SERVER['PHP_SELF']
  • <form method="post" action="<?=$_SERVER['PHP_SELF']?>">

'Engineering WIKI > PHP' 카테고리의 다른 글

[PHP] php 이전 글, 다음 글  (0) 2020.04.26
[PHP] 배열 중복 제거  (0) 2020.03.09
[PHP] PHP & Jquery (select box form submit after selected)  (0) 2020.02.16
[PHP] foreach 예제  (0) 2019.08.12
[PHP] PHP 배열 → JS  (0) 2018.09.01