2011-10-23 3 views
0

아마 내가 누락되었지만 내가하려고하는 것은 등록 양식을 작성하고 확인 이메일을 보낸 후 다른 페이지로 리디렉션하는 것입니다. 내가 무엇을 가지고 지금까지PHP : 진실한 진술에 리디렉션

if($sentmail){ 
<redirection code> 
} 
else { 
echo "Problem sending information, please resubmit."; 
} 

답변

1

당신은 header()를 원하고, 아마도 exit가 처리를 중지 할 수 있습니다.

if ($sentmail) { 
    header('Location: http://example.com/after_true_statement_redirected'); 
    // exit; ??? 
} else { 
    echo "Problem sending information, please resubmit."; 
} 
+0

예, 그는 출구를 지적했습니다. 모든 유형의 http 상호 작용에 대해 리디렉션을 필수로 지정하려면 포함해야합니다. –

+0

누가 지적 했습니까? –

+0

죄송합니다. @ Jared Farrish 님, 가능한 댓글 종료에 대해 언급하셨습니다. –

0

header(); 기능을 사용하면됩니다.

if($sentmail){ 
    header("Location: http://mypage.com/redirect.php"); 
    die(); 
} 
else { 
    echo "Problem sending information, please resubmit."; 
} 

스크립트 실행을 중지하려면 die();을 사용하십시오. 페이지가 리디렉션되지만 스크립트는 여전히 실행됩니다.

+0

감사! 놀랐다 나는 그것을 놓쳤다. –

0

가장 쉬운 리디렉션 통화는 PHP에서 http_redirect입니다. 리디렉션을 위해 필요한 모든 작업을 수행합니다.

if ($sentmail) 
{  
    http_redirect('new location'); 
} 
else 
{ 
    echo "Problem sending information, please resubmit."; 
}