form_action1.php POST방식 폼 데이터 전송 POST method data form transmission

form_action1.php은 폼의 전송 방식이 “POST”방식일때 화면에 화면에 이름과 패스워드를 출력하는 파일 입니다.
전송 방식이 POST방식이 아니면 차단하기 위한 보안 설정입니다.
form_action1.php is a file that displays the name and password on the screen when the form transmission method is “POST”.
This is a security setting to block transmission if the transmission method is not POST.

1.$_SERVER[‘REQUEST_METHOD’]
– 웹페이지에 어떤 방식으로 데이터를 전송 했는지를 확인하기 위한 환경 변수입니다. (request method라고 합니다.)
This is an environment variable to check how data was transmitted to the web page. (It is called request method.)
– 아래는 $_SERVER[‘REQUEST_METHOD’] 관련 설명입니다.
The link below explains $_SERVER[‘REQUEST_METHOD’].
https://www.php.net/manual/en/reserved.variables.server.php

2.$_POST[‘name’];
– from1.php파일에서 post방식으로 넘어온 데이터를 받는 부분입니다.
$_POST[‘name‘]은 form1.php파일의 코드에서 name = “name” 부분이며 “name“이 변수명이 됩니다.
$_POST[‘pswd‘]는 form1.php파일의 코드에서 name=”pswd” 부분이며 “pswd“가 변수명이 됩니다.

This is the part that receives data sent through the post method in the from1.php file.
$_POST[‘name‘] is the name = “name” part in the code of the form1.php file, and “name” becomes the variable name.
$_POST[‘pswd‘] is the name=”pswd” part in the code of the form1.php file, and “pswd” becomes the variable name.

아래링크는 HTTP POST 변수 설명입니다.
The link below explains HTTP POST variables.
https://www.php.net/manual/en/reserved.variables.post

<input type="name" class="form-control" id="name" placeholder="당신의 이름을 입력하세요(Enter Your Name)" name="name">
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pswd">

3.전체코드(full code)

<?php  
if($_SERVER['REQUEST_METHOD'] == "POST"){

   $f_name = $_POST['name'];
   $f_pwd = $_POST['pswd'];
}
echo $f_name."<br>";
echo $f_pwd;
?>

Leave a Reply

Your email address will not be published. Required fields are marked *