-3

I want to use some URL for data to retrieve using post method with redirect rule or without it in PHP. But, as it will have no extension like .php.

Example:- http://localhost/folderA/file

Also, have to send some data in post method. So, please help to get it solved.

Thank you help.

This is the HTML code what I am using.

<!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>

Note:- On the local server, it is working well. But, on the remote server, it is not working. There is no message coming for it. I have used .htaccess for redirecting

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

</IfModule>
  • What you're looking for is called "router". It essentially translates an URL into a script to call. – Dormilich Dec 12 '18 at 13:21
  • Hey there. I don't think you can send files in PHP like that hey. But you can send data from a form to a URL and the do something with the URL parameters :) – 13garth Dec 12 '18 at 13:22
  • I am sending the data from html form to http://localhost/folderA/file. but, it is not working as it has no file extension or folder /. If we make it using redirect rule then, also, it is not working. – saurabh kumar Dec 12 '18 at 13:26
  • You might want the Apache module mod_dir (FallbackResource) https://httpd.apache.org/docs/trunk/mod/mod_dir.html#fallbackresource or mod_rewrite https://httpd.apache.org/docs/trunk/mod/mod_rewrite.html – Pinke Helga Dec 12 '18 at 14:12
  • Nobody can tell you why your code does not work if you do not show it. – Pinke Helga Dec 12 '18 at 14:15
  • Possible duplicate of [jQuery - Redirect with post data](https://stackoverflow.com/questions/19036684/jquery-redirect-with-post-data) – Kebab Programmer Dec 12 '18 at 14:31
  • @ Quasimodo's clone -> You are right. it is based on rewrite mod. Have attached the code what i have used. – saurabh kumar Dec 14 '18 at 07:48
  • And it is not possible using jqyery redirection code. Because in working page, it is being called from third party. Basically, it will be handled using mode_rewrite. But, the data using post not coming there. – saurabh kumar Dec 14 '18 at 07:51

1 Answers1

0

Maybe something like that: Put data in SESSION, then redirect and get data from SESSION.

zaza
  • 26
  • 6