【问题标题】:php post method senderphp post方法发件人
【发布时间】:2014-01-25 10:29:48
【问题描述】:

我需要一个php post方法的解决方案,我有get方法的解决方案。

例子:

文件夹:/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

*/

?>

【问题讨论】:

标签: php post proxy get


【解决方案1】:

您不能使用 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>

【讨论】:

    【解决方案2】:

    您的 post 方法应定义为

                <div class="form-group">
                    <label for="form_name">Firstname *</label>
                    <input id="form_name" type="text" name="name" class="form-control" placeholder="Please enter your firstname *" required="required" data-error="Firstname is required.">
                </div>
            </div>
    

    然后获取 post 值,例如 欢迎

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 2012-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多