如何使用发布数据在PHP中重定向

时间:2018-12-12 13:18:21

标签: php .htaccess

我想使用一些URL来使用带有重定向规则的post方法或没有PHP的post方法来检索数据。但是,因为它没有像.php这样的扩展名。

示例:-http://localhost/folderA/file

此外,还必须使用post方法发送一些数据。因此,请帮助解决该问题。

谢谢您的帮助。

这是我正在使用的HTML代码。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#2f3d44" />

<title>Test</title>


<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
<script>

</script>
</head>
<a name="top"></a>
<style>

html,.wrap{height:100%;}
.wrap{display: inline;}
</style>
<body class="blacker"> 

<div class="modal fade-scale" id="reglogin" tabindex="-1" role="dialog" aria-hidden="true" data-keyboard="false" data-backdrop="static" style="z-index:2001;">
<div class="modal-dialog modal-md">


<div class="loginformpop popdiv">
<div class="form-container signup-form-container">
<h4>LOGIN</h4>
<div class="form-row">
<input type="email" name="email" id="poplogin_email" value="" class="inputbox " maxlength="255" size="50" style="" placeholder="Email">
</div>
<div class="form-row">
<input type="password" name="password" id="poplogin_password" value="" class="inputbox " maxlength="255" size="50" style="" placeholder="Password">
</div>
<div class="form-row form-submit">
<button id="poploginbtn" value="JOIN NOW" class="signupbutton btn btn-danger" onclick="callAuthenticate()">LOGIN</button>
</div>
</div>
</div>

</div>
</div>

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="res/bootstrap.min.js"></script>
<script>
function callAuthenticate(){
    var userAccount = {'UserName':'test2', 'Password':'test123!'};

    var post_data = {"PlayerId":"104", "Account":userAccount};
    $.ajax({
        type: "POST",
        url: "http://host/folderA/file",
          data: post_data,
        dataType: "json",
          xhrFields: {
                       withCredentials: true
        },
        success: function(d){

        },
        error: function(d){
            console.log(d);
        },
        complete: function(){
        }


    })
}

</script>
<script>
$(document).ready(function(){

});
</script>

<div id="hiddenframe" style="height:1px; width:1px;"></div>
</body>
</html>

注意:-在本地服务器上,它运行良好。但是,在远程服务器上,它不起作用。没有消息来了。 我已经使用.htaccess重定向

<IfModule mod_rewrite.c>
RewriteEngine on
Redirect 301 /file /file/index.php

</IfModule>

1 个答案:

答案 0 :(得分:0)

也许是这样的: 将数据放入SESSION,然后重定向并从SESSION获取数据。

相关问题