I have passed some values from a page to another using ajax with request method post. But there is one condition that f some one is directly accessing the url, it should be redirected to some other page. Problem is that its not getting redirected **(In else condition in img.php)** . Can any one tell me what mistake I am committing?

Thanks in advance.

Code:-

imageupload.php:

```
document.getElementById("submit").addEventListener("click", function(event){
    event.preventDefault();
    saveImgfunc();
});

function saveImgfunc(){
    var form = new FormData(document.getElementById('saveImg'));
    var file = document.getElementById('imgVid').files[0];
    if (file) {   
        form.append('imgVid', file);
    }
    $.ajax({
        type : 'POST',
        url : 'core/img.php',
        data : form,
        cache : false,
        contentType : false,
        processData : false
    }).success(function(data){
        document.getElementById('msg').innerHTML = data;
    });
}

```

img.php:

```
<?php
require '../core.php';
$qry = new ProcessQuery('localhost', 'root', '', 'mkart');

$uid = 6;

if($_SERVER["REQUEST_METHOD"] == "POST"){
//Some code here
}
else{
    header("Location : ../core.php");
}

```