2011-05-26 74 views
1

我想使用PHP张贴到一个表单的方式URL。基本上这个表格可以做的功能相同发布到一个URL,但没有形式

<form method="POST" id="foo" action="<?php echo $url; ?>"> 
      <input type="hidden" name="shopId" value="<?php echo $ID; ?>"> 
      <input type="hidden" name="encodedMessage" value="<?php echo $encodedMessage; ?>"> 
      <input type="hidden" name="signature" value="<?php echo $signature; ?>"> 
      <input type="submit" value="Submit" name="buy"> 
    </form></div> 

我该怎么做?

+1

你的意思是如何制作服务器端文章?如果是的话,看看卷曲功能:http://it.php.net/curl – 2011-05-26 17:40:43

+0

使用卷曲为该http://us3.php.net/curl – 2011-05-26 17:40:47

+0

你能够提供一个示例代码,将工作? – Michael 2011-05-26 17:42:00

回答

3

你想用cURL函数发送一个http POST请求。例如:

$ch = curl_init($url); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "name1=val&name2=val2..."); 
curl_exec($ch); 
curl_close($ch); 
0

有几种方法可以做到这一点,但最简单的是可能与file_get_contents()函数和stream_context_create()。一个例子见file_get_contents() comment