form 관련 질문입니다. 채택완료

page1.php

Copy
<!doctype html>

<html>

    <head>

        <meta charset="utf-8">

        <title>Form Test</title>

    </head>

    <body>

        <form name="ftest" id="ftest" action="./page2.php">

            <input type="text" name="f_attr1">

            <iframe src="./form.html">Loading...</iframe>

            <input type="submit" value="asdf">

        </form>

    </body>

</html>

 

form.html

Copy
<!doctype html>

<html>

    <head>

        <meta charset="utf-8">

    </head>

    <body>

        <input type="text" name="f_attr2">

    </body>

</html>

 

위와 같이 구성했을때, page1.php에서 폼을 제출하면 page2.php로 갔을때 f_attr2 변수가 포함되도록 할 수 있나요?

답변 3개

채택된 답변
+20 포인트

form.html

Copy
<?php

$f_attr2 = $_REQUEST["f_attr2"];

?>


<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <input type="text" name="f_attr2" value="<?php echo $f_attr2; ?>">
    </body>
</html>
로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

무슨원리로 돌아가는 건지 궁금한데...

댓글을 작성하려면 로그인이 필요합니다.

https://www.w3schools.com/php/php_forms.asp

여기를 참고하세요.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

Form 이라는건 다른 페이지로 값을 전달하는거에요. 그렇게 전달하면 리퀘스트 , 겟, 포스트로 전달 받을 수 있다고 약속이 정해진거에요. 이건 그냥 규

칙이자 모두의 약속이에요.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고