使用php://input

就是一个输入流, 可以获得POST的原始数据.

echo file_get_contents("php://input");

//示例代码

//test.html

  1. <html>
  2. <head>
  3. <!--set title-->
  4. <title> test php://input </title>
  5. </head>
  6. <!--show page-->
  7. <body>
  8. <form action = "input.php" method="post">
  9. 用户名: <input type="text" name="user"> <br>
  10. 密码:<input type="password" name="password"> <br>
  11. <input type="submit">
  12. </form>
  13. </body>
  14. </html>

//input.php

  1. <html>
  2. <head>
  3. <!--set title-->
  4. <title> test php://iput web </title>
  5. </head>
  6. <!--show page-->
  7. <body>
  8. <?php
  9. echo"post data: <br>/n";
  10. echofile_get_contents("php://input");
  11. ?>
  12. </body>
  13. </html>

 

posted @ 2012-07-09 10:43  Lxsec  阅读(506)  评论(0)    收藏  举报