Login script

Greetings!

I’m using mootols.js to show my validations, and I got it working to show the errors.
My problem is when I put the right username and password it doesn’t redirect to its page.

login.html


<?php
include "include/session.php";
include "include/z_db.php";
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title></title>
<script type="text/javascript" src="../js/mootools.js"></script>
	<script type="text/javascript">
		window.addEvent('domready', function(){
	                $('registerForm').addEvent('submit', function(e) {
	                    new Event(e).stop();
	                    var log = $('log_res').empty().addClass('ajax-loading');
	                    this.send({
	                        update: log,
	                        onComplete: function() {
	                            log.removeClass('ajax-loading');
	                        }
	                    });
	                });
	            });
	</script>
</head>
<body>
<form id ="registerForm"  action = "loginck.php" method = "post">
<table>
login ID: <input type ='text' class='bginput' name='userid' id='userid' ></font></td></tr>
Password: <input type ='password' class='bginput' name='password' ></font></td></tr>
<input type='submit' value='Submit' /> 
</table></center>
</form>
<div id="log">
		<div id="log_res">
		<!-- SPANNER -->
		</div>
		</div>
</body>
</html>

loginck.php


<?php
include "include/session.php";
include "include/z_db.php";

$userid=$_POST['userid'];
$password=$_POST['password'];

?>

<?php
$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);


if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tbl_admin WHERE admin_uname ='$userid' AND admin_Password = '$password'")))
{
	if(($rec['admin_uname']==$userid)&&($rec['admin_Password']==$password))
	{
	//include "include/newsession.php";
	$user = 'admin';
	}
}
if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tbl_faculty WHERE fac_Id ='$userid' AND fac_Password = '$password'")))
{
	if(($rec['fac_Id']==$userid)&&($rec['fac_Password']==$password))
	{
	//include "include/newsession.php";
	$user = 'faculty';
	}
}
else { echp 'Invalid user name and pass';}
	  
switch($user)
{
	case "admin";
	echo "<meta http-equiv=\\"refresh\\"content=\\"0;URL=../admin.html\\">";	
	break;
	
	case "faculty";
	echo "<meta http-equiv=\\"refresh\\"content=\\"0;URL=../faculty.html\\">";
	break;
}


Any help is really appreciated. Thank you.

First of all, is it true that you have included some PHP files (sessions.php & z_db.php) in your html page? Is sessions.php file for starting the session? That might make hamper on properly functioning. Change HTML file to php i.e. login.html to login.php

Secondly, why are you using meta refresh for redirection? Do PHP header redirection instead as below:


switch($user)
{
    case "admin";
        header("Location: ../admin.html");
        exit;
        break;
    case "faculty";
        header("Location: ../faculty.html");
        exit;
        break;
}

Hope that will help to figure out the problems.

Thank you very much for the response sir.
My login page is in login.php …

I changed already meta to header but still no work.