the redirection page doesnt work proper ?in php with phpmyadmin : i have written my code in php as well as in html for my final project which is the the course registration system for the collage my problem is if i need to redirect the page for one user it works but later when i used the switch statement for redirect a different pages based on role by retrive the data from the phpmyadmin it dosent work here is my code ;
------------------------------------------------------------------------

 

     <?php
                    $host="localhost";
                    $username="root";
                    $password="";
                    $db="login";
                    mysql_connect($host,$username,$password);
                    mysql_select_db($db);
                   
                    if(isset($_POST['username'])){

                        $username= $_POST['username'];
                        $password= $_POST['password'];
                        $sql="select * from loginform where username='$username' AND password='$password' ";
                        $result=mysql_query($sql);
                        $result=mysql_query($role);
                        $role="SELECT * FROM loginform  username='$username' AND password='$password'";

                        if(mysql_num_rows($result)==1){
                            session_start();
                            switch($role)
                            {
                                case 1:
                                    $_SESSION['role']='admin';
                                    header("Location: http://localhost/test/form1.html");
                                    break;
                                case 2:
                                    $_SESSION['role']='faculty';
                                    header("Location: http://localhost/test/faculty.html");
                                    break;
                                case 2:
                                    $_SESSION['role']='student';
                                    header("Location: http://localhost/test/student.html");
                                    break;
                            }
                            
                            
                            echo " You Have Successfully Logged in"; 
                            exit();
                            
                        }
                    
                        else{ 
                            
                            $message='Worning !!! ...Incorrect UserName or PassWord';
                            echo "<script type='text/javascript'>alert('$message');</script>";
                            exit();
                            header("Location: http://localhost/test/loginn.php");
                        }
                    }
            ?>
