I have a problem with http_referer.
I have 1 file, index.php that has form and when the form is submitted, information like the http_referer is submitted.
There's another file, index.html that runs an ajax script that submits the same info as index.php file would but with just a click of a button.
When I run the action from index.php the http_referer is localhost/index.php When I run the ajax script from index.html the http_referer is localhost/index.html
how can I make the http_referer be localhost/index.php from the index.html?
Someone suggested I framed index.php in index.html but when I did that and ran the ajax script the http_referer was still localhost/index.html
Edit: Ajax file added
function ajax_func(){
var ajax;
if(window.XMLHttpRequest){
ajax = new XMLHttpRequest();
} else {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
ajax.onreadystatechange = function(){
if(ajax.readyState == 4 && ajax.status == 200){
}
}
ajax.open('POST', 'index.php', true);
ajax.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
ajax.send('name=johndoe&email=jd@email.com&tasks=value');
alert('script ran');
}
HTTP_REFERER is the page where you were before you went to the next page. If you run anything from index.html that leads elsewhere, the http_referer is index.html. Likewise with index.php. So, you cannot make index.php the http_referer when executing from index.html.
As an example, I use it in php to return to the initial page. This way, I can use a single script for multiple pages. (obvious and simple, I know)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.