0

If my php string is like this. $ResponseG is my string.

$responseG = $_SESSION['id']." | ";
$responseG .= $_SESSION['type']." | ";
$responseG .= $_SESSION['username']." | ";
$responseG .= $_SESSION['last_active']." | ";
$responseG .= $_SESSION['last_login']." | ";

Which would be something like this.

2 | user | username | time1 | time2

Here is the Ajax

if(RequestObject){
RequestObject.open("POST", "calls/checkLog.php");
RequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
RequestObject.onreadystatechange = function(){
if(RequestObject.readyState == 4 && RequestObject.status == 200){
if(RequestObject.readyState == 4){
if(RequestObject.responseText !== "Username or Password are Invalid!"){
if(RequestObject.responseText !== "Username and Password are Required to Continue."){
window.location.replace("http://folder/members.php");
}else{document.getElementById('alertLog').innerHTML = RequestObject.responseText;}
}else{document.getElementById('alertLog').innerHTML = RequestObject.responseText;}}}}
var dataStringA = document.getElementById('inputaID').value;
var dataStringB = document.getElementById('password').value;
var data = dataStringA+'|'+dataStringB+'|';
RequestObject.send("data=" + data);}
return false;}

In this section i was wanting to sent the string to the redirected URL How do i send the php string to the members.php page

window.location.replace("http://folder/members.php");

Please no jQuery. The solution must be in native Javascript. Thanks in Advance.

4
  • window.location.replace('<?php echo $url; ?>'); Commented Jan 4, 2018 at 3:56
  • The url is fine when redirecting i want to send the php string of data with the url redirect. The Redirected Url does a check for the data in the string. Commented Jan 4, 2018 at 4:01
  • i would like to send the data to the new url Commented Jan 4, 2018 at 4:02
  • 1
    window.location.replace('http://folder/members.php?data='+data); Commented Jan 4, 2018 at 4:24

1 Answer 1

2

This can be done by passing the response in the query string of the URL:

window.location.replace("http://folder/members.php?userInfo=" + encodeURIComponent(RequestObject.responseText));

You should then be able to access the passed data in members.php using $_GET['userInfo']

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.