_GET, _POST > 저장하자

본문 바로가기
  • 맑음
  • 경기도 (25.0'C)
  • 2024.05.02 (목)
사이트 내 전체검색

저장하자

php _GET, _POST

페이지 정보

profile_image
작성자 neue
댓글 0건 조회 1,080회 작성일 22-11-27 03:12

본문

적용예 청소년수련원

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]

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

 

상황에 맞추어 본인이 원하는 형태로 넘겨주면 됩니다.

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

회사명 : 회사명 / 대표 : 대표자명
주소 : OO도 OO시 OO구 OO동 123-45
사업자 등록번호 : 123-45-67890
전화 : 02-123-4567 팩스 : 02-123-4568
통신판매업신고번호 : 제 OO구 - 123호
개인정보관리책임자 : 정보책임자명

공지사항

  • 게시물이 없습니다.

접속자집계

오늘
961
어제
1,493
최대
3,311
전체
139,027
Copyright © 소유하신 도메인. All rights reserved.

    상담 안내
  • 123.4567.8900
    평일 오전 10시 ~ 오후 6시
    점심시간 : 오후 12시 ~ 오후 1시 30분