CI 묻고 답하기

제목 controller에서 post data 처리
글쓴이 엘라오빠 작성시각 2015/02/24 11:11:12
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 18224   RSS
안녕하세요. php도 처음이고 codeigniter도 처음 사용하는 개발자입니다.
프로젝트에서 사용해야 해서 예제따라서 만들어 보고 있는 중입니다.

프로젝트내에서도 php 사용하는 분들이 없어서 질문 드려 봅니다.

저장 시 받은 post data를 저장 완료 후 조회 function에 그대로 post 형태로 넘기고 싶은데요.

한 콘트롤러 안에서 

saev() function에서 저장 완료 후

$this->index(); 이런식으로 처리하면 

index() function에서 post로 데이터를 받아서 조회가 진행이 됩니다.

그런데 페이지 상단 url 에 '/xxx/save' 이런식으로 표시가 되더라구요.

그래서 redirect('/xxx/index')를 사용을 했는데 post data가 넘어가지를 않더라구요.

flashdata 같은 것을 사용하지 않고 post 형태로 데이터를 넘기고 싶은데요.

index에 데이터 받는 부분이 post처리가 되어 있어서요.

혹시 

save() 에서 $this->index();

이렇게 다른 function을 호출 했을 때 xxx/save 대신에 xxx/index 이렇게 화면에 표시가 되던지

아니면 redirect 했을 경우 데이터를 post 형태로 넘겨 줄수는 없나요?
 다음글 다국어 처리관련 (6)
 이전글 form action시 controller의 index... (2)

댓글

한대승(불의회상) / 2015/02/24 12:05:20 / 추천 0
리다이렉트로는 post data를 전달 할 수 없습니다.
ci세상 / 2015/02/24 12:07:03 / 추천 0
V
<html>
<head>
<title>My Form</title>
</head>
<body>

<?php echo validation_errors(); ?>

<?php echo form_open('/welcome/saev'); ?>

<h5>Username</h5>
<input type="text" name="username" value="" size="50" />

<h5>Password</h5>
<input type="text" name="password" value="" size="50" />

<h5>Password Confirm</h5>
<input type="text" name="passconf" value="" size="50" />

<h5>Email Address</h5>
<input type="text" name="email" value="" size="50" />

<div><input type="submit" value="Submit" /></div>

</form>

</body>
</html>

C
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {

 public function index()
 {
  print_r($_POST);
 }

 public function saev()
 {
  $this->index();
 }
}


결과
Array ( [username] => 1[password] => 2[passconf] => 3[email] => 4)


C에서 동일 메소드 호출하면 post 정상 전송 되는데요 ~


redirect는 get방식이다 보니 curl > post는 어떨까요?