Im working with a combination of Ajax (with native JavaScript) and php to construct a login from.
The from sits in a php file (login.php). When it gets submitted, it runs a JS onlclick function which posts the form data to another php file which validates the form data :
<input type="button" name="submit" value="Submit" onclick="JavaScript:xmlhttpPost('validator.php')"/>
The results from validator.php are returned in a div using JavaScript:
function updatepage(str){
document.getElementById("result").innerHTML = str;
}
Finally if the password and username are both correct, validator.php runs a redirect like this:
if ( // form data is valid ) {
header("Location: welcome.php");
}
However, because everything's running through ajax, this results in the "welcome.php" page being displayed in the "results" div on the original login page.
Is there a way to send a redirect via JavaScript instead?