一个简单的PHP接收参数页面
<?php
    header("content-type:text/html;charset=utf-8");
    if($_POST[username] == "admin" && $_POST[password] == "123456") {
        echo "登陆成功";
    }else {
        echo "登陆失败";
    }
?>
nodejs代码实现模拟登陆示例
var http = require("http");
var querystring = require("querystring"); 
var contents = querystring.stringify({
    username: 'admin',
    password: '123456'
});
var options = {
    hostname: 'localhost',
    port: 9000,
    path: '/modules/login/checkSign.php',
    method: 'POST',
    headers:{
        "Content-Length":contents.length,
        "Content-Type":"application/x-www-form-urlencoded"
  } };

var req = http.request(options, function(res) { res.setEncoding('utf8'); res.on('data', function (data) { console.log('BODY:' + data); }); }); req.on('error', function(e) { console.log('problem with request: ' + e.message); }); req.write(contents); req.end();

 

相关文章:

  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
猜你喜欢
  • 2022-12-23
  • 2021-10-10
  • 2021-05-20
  • 2021-12-27
  • 2021-11-15
  • 2021-12-20
  • 2021-11-15
相关资源
相似解决方案