I want to redirect logged in users to home page(member-index.php), I have used the following code to accomplish this, but this doesn't work. 

```
<?php

function redirect() {
header('location:member-index.php');
}
 ?> 
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <?php
  if(isset($_SESSION['SESS_FIRST_NAME'])){
   redirect();
  }
?> 

<form id="loginForm" name="loginForm" method="post" action="login-exec.php">
    <input name="email" type="text" class="textfield" id="login" placeholder="username" />
    <input name="password" type="password" class="textfield" id="password" placeholder="password"/>
    <input type="submit" name="Submit" value="LOGIN" />
</form>
</body>
</html>

```

session variables at (login-exec.php)

```
 $qry="SELECT * FROM members WHERE email='$login' AND passwd='".md5($_POST['password'])."'";
$result=mysql_query($qry);

//Check whether the query was successful or not
if($result) {
    if(mysql_num_rows($result) == 1) {
        //Login Successful
        session_regenerate_id();
        $member = mysql_fetch_assoc($result);
        $_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
        $_SESSION['SESS_FIRST_NAME'] = $member['fullname'];

```

The other pages with sessions, works perfectly fine, I could get and print the logged in user on another page, But couldn't get session work in login-form page.. 
Any help would be appreciated!