I want to know that how to redirect url after login successful via Ajax call in php? Kindly check my code what I am doing wrong.

Below is the registration.php file on url <http://localhost:8080//myproject/adminseller/registration.php>:

```
<script>
function createLogin () {
//alert("Hello! I am an alert box!!");

var data = {

'email'     : jQuery('#email').val(),
'password'  : jQuery('#password').val(),
 };  // data obect End

//Ajax call Start Here
jQuery.ajax({
url : '/myproject/adminseller/login.php',
method : 'POST',
data : data,
success : function(data){
//alert(data);  // For checking Code in alert

if (data != 'passed') { // passed is else statement in 
check_address.php when no errors are showing
  jQuery('#modal_errors_1').html(data);
}

if (data == 'passed') {
  //alert('passed!');

  //clear the errors if any
  jQuery('#modal_errors_1').html("");
  location.reload();
  } 
  },
  error : function (){alert("Something went wrong.");},

  });    

  }

  </script>

```

Below is the Login.php File

```
<?php

   if (isset($_POST['email'])) {
   $email = sanitize($_POST['email']);
 }

  if (isset($_POST['password'])) {
   $password = sanitize($_POST['password']);
 }

 // echo $email; // Output x2a0889@gmail.com
 // echo $password; // 123456

 // Email and password matched and no erros so I am removing validations code from here, So else condition will execute here

 // Check for Errors
    if (!empty($errors)) {
      echo display_errors($errors);
    }else{

      // Assume here login is successful
      echo 'passed';

        **// Here is the problem via Ajax Call url is not redirecting after login successful, and always getting url is: http://localhost:8080//myproject/adminseller/registration.php **
          header('Location:index.php');

    }

  ?>

```

My problem is that after successful login the url is not changing it still
<http://localhost:8080//myproject/adminseller/registration.php>

And I want to redirect my page <http://localhost:8080//myproject/adminseller/index.php>

After successful login.

Any idea or suggestion would be welcome.