php _GET, _POST
페이지 정보
본문
적용예 청소년수련원
view.skin.php
[code]
<form action="<?php echo get_pretty_url("application","write"); ?>" method="post">
<input type="hidden" name="subject1" value="<?php echo $view['wr_subject'];?>" >
<input type="hidden" name="sca1" value="<?php echo $view['ca_name']; ?>" >
<input type="hidden" name="start1" value="<?php echo $view['wr_1'];?>" >
<input type="hidden" name="end1" value="<?php echo $view['wr_2']?>" >
<input type="hidden" name="count1" value="<?php echo $view['wr_id']?>" >
<div class="btn1"><input type="submit" value="프로그램 신청하기" style="cursor:pointer" class="bt_list3"></div>
</form>
[/code]
write.skin.php
[code]
<div class="bo_w_tit write_div">
<label for="ca_name" class="sound_only">분류<strong>필수</strong></label>
<input type="text" name="ca_name" value="<?php echo $write['ca_name'] ? $write['ca_name'] : $_POST['sca1']?>" id="ca_name" readonly class="frm_input" style="background-color:#eee;" size="50" maxlength="255" placeholder="분류">
<label for="wr_link1" class="sound_only">고유아이디<strong>필수</strong></label>
<input type="text" name="wr_link1" value="<?php echo $write['wr_link1'] ? $write['wr_link1'] : $_POST['count1']?>" id="wr_link1" readonly class="frm_input" style="background-color:#eee;" size="50" maxlength="255" placeholder="고유아이디" style="width:20%;">
</div>
<div class="bo_w_tit write_div">
<label for="wr_subject" class="sound_only">제목<strong>필수</strong></label>
<input type="text" name="wr_subject" value="<?php echo $write['wr_subject'] ? $write['wr_subject'] : $_POST['subject1']?>" id="wr_subject" readonly class="frm_input full_input" style="background-color:#eee;" size="50" maxlength="255" placeholder="프로그램명">
</div>
<div class="bo_w_info write_div">
<label for="wr_1" class="sound_only">일정시작일<strong>필수</strong></label>
<input type="text" name="wr_1" value="<?php echo $write['wr_1'] ? $write['wr_1'] : $_POST['start1']?>" id="wr_1" class="frm_input" readonly style="background-color:#eee;" placeholder="일정시작일">
<label for="wr_2" class="sound_only">일정종료일</label>
<input type="text" name="wr_2" value="<?php echo $write['wr_2'] ? $write['wr_2'] : $_POST['end1']?>" id="wr_2" class="frm_input" readonly style="background-color:#eee;" placeholder="일정종료일">
</div>
[/code]
비타주리 님의 답변
2021-08-09 18:21:59 58.♡.♡.93
그냥 아주 일반적인 예로 설명을 하자면...
a 페이지에서 b페이지로 값을 넘기는 방식은 크게 4가지가 있습니다.
쉬운예제로 이미지주소를 하나 넘겨서 이미지태그를 걸어 보겠습니다.
1. form - input 에 name 을 주고 POST 로 넘기는 방식
a.php
[code]
<form action=b.php method=POST>
<input type=text name=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<input type=submit value=전송 style=cursor:pointer>
</form>
[/code]
b.php
[code]
<?php
$img = $_POST['my'];
?>
<img src=<?php echo $img; ?> style=width:400px>
[/code]
--------------------
1. form - input 에 name 을 주고 GET 으로 넘기는 방식
aa.php
[code]
<form action=bb.php method=GET>
<input type=text name=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<input type=submit value=전송 style=cursor:pointer>
</form>
[/code]
bb.php
[code]
<?php
$img = $_GET['my'];
?>
<img src=<?php echo $img; ?> style=width:400px>
[/code]
--------------------
3. input 에 id 를 주고 GET변수를 링크로 딸려보내는 방식
aaa.php
[code]
<input type=text id=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<script>
function myMove() {
location.href = "bbb.php?my=" + my.value;
}
</script>
<button onclick=myMove() style=cursor:pointer>클릭</button>
[/code]
bbb.php
[code]
<?php
$img = $_GET['my'];
?>
<img src=<?php echo $img; ?> style=width:400px>
[/code]
--------------------
4. 자바스크립트에서 로컬스토리지나 세션스토리지의 변수로 저장한 후 링크하는 방식
aaaa.php
[code]
<input type=text id=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<script>
function myMove() {
sessionStorage.saveData = my.value;
location.href = "bbbb.php";
}
</script>
<button onclick=myMove() style=cursor:pointer>클릭</button>
[/code]
bbbb.php
[code]
<script>
document.write("<img src=" + sessionStorage.getItem('saveData') + " style=width:400px>");
</script>
[/code]
--------------------
상황에 맞추어 본인이 원하는 형태로 넘겨주면 됩니다.
view.skin.php
[code]
<form action="<?php echo get_pretty_url("application","write"); ?>" method="post">
<input type="hidden" name="subject1" value="<?php echo $view['wr_subject'];?>" >
<input type="hidden" name="sca1" value="<?php echo $view['ca_name']; ?>" >
<input type="hidden" name="start1" value="<?php echo $view['wr_1'];?>" >
<input type="hidden" name="end1" value="<?php echo $view['wr_2']?>" >
<input type="hidden" name="count1" value="<?php echo $view['wr_id']?>" >
<div class="btn1"><input type="submit" value="프로그램 신청하기" style="cursor:pointer" class="bt_list3"></div>
</form>
[/code]
write.skin.php
[code]
<div class="bo_w_tit write_div">
<label for="ca_name" class="sound_only">분류<strong>필수</strong></label>
<input type="text" name="ca_name" value="<?php echo $write['ca_name'] ? $write['ca_name'] : $_POST['sca1']?>" id="ca_name" readonly class="frm_input" style="background-color:#eee;" size="50" maxlength="255" placeholder="분류">
<label for="wr_link1" class="sound_only">고유아이디<strong>필수</strong></label>
<input type="text" name="wr_link1" value="<?php echo $write['wr_link1'] ? $write['wr_link1'] : $_POST['count1']?>" id="wr_link1" readonly class="frm_input" style="background-color:#eee;" size="50" maxlength="255" placeholder="고유아이디" style="width:20%;">
</div>
<div class="bo_w_tit write_div">
<label for="wr_subject" class="sound_only">제목<strong>필수</strong></label>
<input type="text" name="wr_subject" value="<?php echo $write['wr_subject'] ? $write['wr_subject'] : $_POST['subject1']?>" id="wr_subject" readonly class="frm_input full_input" style="background-color:#eee;" size="50" maxlength="255" placeholder="프로그램명">
</div>
<div class="bo_w_info write_div">
<label for="wr_1" class="sound_only">일정시작일<strong>필수</strong></label>
<input type="text" name="wr_1" value="<?php echo $write['wr_1'] ? $write['wr_1'] : $_POST['start1']?>" id="wr_1" class="frm_input" readonly style="background-color:#eee;" placeholder="일정시작일">
<label for="wr_2" class="sound_only">일정종료일</label>
<input type="text" name="wr_2" value="<?php echo $write['wr_2'] ? $write['wr_2'] : $_POST['end1']?>" id="wr_2" class="frm_input" readonly style="background-color:#eee;" placeholder="일정종료일">
</div>
[/code]
비타주리 님의 답변
2021-08-09 18:21:59 58.♡.♡.93
그냥 아주 일반적인 예로 설명을 하자면...
a 페이지에서 b페이지로 값을 넘기는 방식은 크게 4가지가 있습니다.
쉬운예제로 이미지주소를 하나 넘겨서 이미지태그를 걸어 보겠습니다.
1. form - input 에 name 을 주고 POST 로 넘기는 방식
a.php
[code]
<form action=b.php method=POST>
<input type=text name=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<input type=submit value=전송 style=cursor:pointer>
</form>
[/code]
b.php
[code]
<?php
$img = $_POST['my'];
?>
<img src=<?php echo $img; ?> style=width:400px>
[/code]
--------------------
1. form - input 에 name 을 주고 GET 으로 넘기는 방식
aa.php
[code]
<form action=bb.php method=GET>
<input type=text name=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<input type=submit value=전송 style=cursor:pointer>
</form>
[/code]
bb.php
[code]
<?php
$img = $_GET['my'];
?>
<img src=<?php echo $img; ?> style=width:400px>
[/code]
--------------------
3. input 에 id 를 주고 GET변수를 링크로 딸려보내는 방식
aaa.php
[code]
<input type=text id=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<script>
function myMove() {
location.href = "bbb.php?my=" + my.value;
}
</script>
<button onclick=myMove() style=cursor:pointer>클릭</button>
[/code]
bbb.php
[code]
<?php
$img = $_GET['my'];
?>
<img src=<?php echo $img; ?> style=width:400px>
[/code]
--------------------
4. 자바스크립트에서 로컬스토리지나 세션스토리지의 변수로 저장한 후 링크하는 방식
aaaa.php
[code]
<input type=text id=my value=https://blog.kakaocdn.net/dn/cMVe4H/btq5RuQIRfF/DkSPyZQhLMVpy26P86Sp40/img.jpg style=width:600px>
<script>
function myMove() {
sessionStorage.saveData = my.value;
location.href = "bbbb.php";
}
</script>
<button onclick=myMove() style=cursor:pointer>클릭</button>
[/code]
bbbb.php
[code]
<script>
document.write("<img src=" + sessionStorage.getItem('saveData') + " style=width:400px>");
</script>
[/code]
--------------------
상황에 맞추어 본인이 원하는 형태로 넘겨주면 됩니다.
관련링크
-
https://sir.kr/qa/425621
350회 연결
- 이전글솔리드파워텍에 쓰였던 메뉴정리 23.01.16
- 다음글이름 중간에 별표 가리기 22.11.25
댓글목록
등록된 댓글이 없습니다.