2014-01-25 36 views
0

我需要一個PHP post方法的解決方案,我有get方法的解決方案。php post方法發件人

實施例:

文件夾:/ vaibrother


第一文件來源:data_get.php

<?php 

$data="nasir=90,sajib=80,masum=100,yeasin=110,mayeen=99"; 

$data=explode(",",$data); 
for($i=0; $i<count($data); $i++){ 

$ns=explode("=",$data[$i]); 
$name=$ns[0]; $score=$ns[1]; 

if(isset($_GET["id"]) && $_GET["id"] == $name) $output = "$name = $score"; 

} if(!empty($output)) echo $output; ?> 

<hr> 
<form action="" method="GET"> 

<input name="id" value="masum"> {example: nasir, sajib, masum, yeasin, mayeen} 

<input type="submit" value="check"> 

</form> 

第二文件來源:data_post.php

<?php 

$data="nasir=90,sajib=80,masum=100,yeasin=110,mayeen=99"; 

$data=explode(",",$data); 
for($i=0; $i<count($data); $i++){ 

$ns=explode("=",$data[$i]); 
$name=$ns[0]; $score=$ns[1]; 

if(isset($_POST["id"]) && $_POST["id"] == $name) $output = "$name = $score"; 

} if(!empty($output)) echo $output; ?> 

<hr> 
<form action="" method="POST"> 

<input name="id" value="masum"> {example: nasir, sajib, masum, yeasin, mayeen} 

<input type="submit" value="check"> 

</form> 

第三文件來源:get_success.php

This is a proxy<hr> 

<?php 

$fp=fopen("http://localhost/vaibrother/data_get.php?id=mayeen","r"); 
echo fread($fp,99999); 
fclose($fp); 

?> 

第四檔來源:post_success.php{} ??????

(我需要該文件的解決方案)

This is a proxy<hr> 

<?php 

/* 

http://localhost/vaibrother/data_post.php 

id = mayeen 

[ How to display result 99 ? ] 

I Dont Know 

*/ 

?> 
+0

捲曲:http://uk3.php.net/curl或不捲曲:http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/ – Steve

+0

您正在尋找的是如何進行POST請求。 http://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php – YRM

+0

我需要像我這樣的例子 – NASIRUDDIN

回答

0

您無法使用PHP將數據作爲POST發送。解決方法可以找到here。 一些方法包括使用FORM將POST數據發送到特定的PHP文件。例如:

<html> 
<body> 
    <form name="POSTFORM" method="post" action="http://localhost/vaibrother/data_post.php"> 
     <input type="text" name="id" value="mayeen"> 
     <input type="submit" value="Submit"> 
    </form> 
</body> 
</html>