그래서, 내가 달성하고자하는 것은 자동 게시 PHP 폼을 가지고 있으며, 다른 페이지로 리다이렉트하는 외부 페이지 (CURL 사용)에 POST가 있습니다. 현재, 어떤 일이 일어나고있는가 (contact.php에있는) 폼에서 "Submit"을 클릭하면 (POST (self-posting) 폼이기 때문에) POST 될 것입니다. 그런 다음 스크립트는 CURL을 사용하여 POST를 준비하고 게시를 수행합니다. 외부 페이지가 처리를 수행 한 다음 외부 페이지가 참조 도메인의 다른 페이지로 다시 리디렉션됩니다. 그러나, 그 대신에 contact.php 페이지가 외부 페이지가 리디렉션 된 페이지에서 HTML을로드 한 다음 contact.php의 HTML이 같은 페이지에서로드되는 것처럼 보입니다.PHP 양식을 다른 URL로 리다이렉트하여 외부 URL에
효과는 두 페이지가 한 페이지로 렌더링 된 것처럼 보입니다. 당연히 POST를 수행하고 브라우저가 외부 페이지에서 지정한대로 리디렉션 할 페이지를 렌더링하게해야합니다. 당신이 거의 다 같은
<?php
if(isset($_POST['submit']))
{
doCURLPost();
}
function doCURLPost()
{
$emailid = "2, 4";
$hotel = $_POST['hotel'];
//you will need to setup an array of fields to post with
//then create the post string
$data = array ("recipient" => $emailid,
"subject" => "Hotel Contact Form",
"redirect" => "http://www.localhost.com/thanx.htm",
"Will be staying in hotel: " => $_POST['hotel'],
"Name" => $_POST['Name'],
"Phone" => $_POST['Phone'],
"Comments" => $_POST['Comments']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.externallink.com/external.aspx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Referer: http://www.localhost.com/contact.php"));
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
}
?>