How to do javascript redirect and enable send data

I am developing a web application. There are several users in this application.

All users can see and use the search form - however, only those who are logged in can submit the form properly.

So, when the form is submitted - BEFORE going to the results page and showing the results, the jquery ajax function is launched, it checks if the user is logged in, and if the user is logged in, window.location.replace('searchresults.php') to the page search results.

How can I make sure that the correct POST data (from the form input fields) is included in the redirect?

+4
source share
2 answers

Create a hidden form and submit it via javascript instead of window.location.replace('searchresults.php')

+8
source

You cannot do window.location redirection and provide POST data. The HTTP specification simply does not support the redirect header with any POST data.

I think your searchresults.php page should always load, but if they are not logged in, do not search. Far simpler.

0
source

Source: https://habr.com/ru/post/1336335/


All Articles